/** * Handle an attribute */ public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties) throws XPathException { int nc = newPool.allocate(oldPool.getPrefix(nameCode), oldPool.getURI(nameCode), oldPool.getLocalName(nameCode)); nextReceiver.attribute(nc, typeCode, value, locationId, properties); }
public String toString(NamePool pool) { switch (nodeKind) { case Type.ELEMENT: return "element(" + pool.getClarkName(fingerprint) + ", xs:anyType)"; case Type.ATTRIBUTE: return "attribute(" + pool.getClarkName(fingerprint) + ", xs:anyAtomicType)"; case Type.PROCESSING_INSTRUCTION: return "processing-instruction(" + pool.getDisplayName(fingerprint) + ')'; case Type.NAMESPACE: return "namespace(" + pool.getDisplayName(fingerprint) + ')'; } return pool.getDisplayName(fingerprint); }
/** * Find an attribute by expanded name * @param uri the namespace uri * @param localName the local name * @return the index of the attribute, or -1 if absent */ private int findByName(String uri, String localName) { if (namePool == null) { return -1; // indicates an empty attribute set } int f = namePool.getFingerprint(uri, localName); if (f == -1) { return -1; } return findByFingerprint(f); }
private void computeUriAndLocal() { if (uri == null) { uri = namePool.getURI(fingerprint); } if (localName == null) { localName = namePool.getLocalName(fingerprint); } }
/** * Make a structuredQName from a Namepool nameCode * @param pool the NamePool * @param nameCode a name code that has been registered in the NamePool */ public StructuredQName(NamePool pool, int nameCode) { this(pool.getPrefix(nameCode), pool.getURI(nameCode), pool.getLocalName(nameCode)); }
/** * Output an item (atomic value or node) to the sequence */ public void append(Item item, int locationId, int copyNamespaces) throws XPathException { if (item instanceof AtomicValue) { final NamePool pool = getNamePool(); out.startElement(resultAtomicValue, StandardNames.XS_UNTYPED, 0, 0); AtomicType type = (AtomicType)((AtomicValue)item).getItemType(getConfiguration().getTypeHierarchy()); int nameCode = type.getNameCode(); String prefix = pool.getPrefix(nameCode); String localName = pool.getLocalName(nameCode); String uri = pool.getURI(nameCode); if (prefix.length() == 0) { prefix = pool.suggestPrefixForURI(uri); if (prefix == null) { prefix = "p" + uri.hashCode(); } } int nscode = pool.allocateNamespaceCode(prefix, uri); String displayName = prefix + ':' + localName; out.namespace(nscode, 0); out.attribute(xsiType, StandardNames.XS_UNTYPED_ATOMIC, displayName, 0, 0); out.startContent(); out.characters(item.getStringValue(), 0, 0); out.endElement(); } else { ((NodeInfo)item).copy(this, NodeInfo.ALL_NAMESPACES, true, locationId); } }
int nameCode = getNamePool().allocate(parts[0], nsuri, parts[1]); FixedAttribute inst = new FixedAttribute(nameCode, validationAction, String p = getNamePool().suggestPrefixForURI( ((StringLiteral)namespace).getStringValue()); if (p != null) { int nameCode = getNamePool().allocate(parts[0], nsuri, parts[1]); FixedAttribute inst = new FixedAttribute(nameCode, validationAction,
private void setUrlAttribute(NamePool pool, String element, String attribute) { int elcode = pool.allocate("", NamespaceConstant.XHTML, element) & NamePool.FP_MASK; int atcode = pool.allocate("", "", attribute) & NamePool.FP_MASK; Long key = new Long(((long)elcode)<<32 | (long)atcode); urlTable.add(key); }
public void start(int i) { out.startElement("ruleChain"); out.emitAttribute("key", out.getNamePool().getClarkName(i)); }
/** * Get the namespace URI of the QName. * * @return the URI. Returns the empty string to represent the no-namespace */ public String getURI() { return pool.getURI(fingerprint); }
/** * Get the local part of the QName * * @return the local part of the QName */ public String getLocalPart() { return pool.getLocalName(fingerprint); }
private String getPrefixForNamespace(String namespace) { String prefix = config.getNamePool().suggestPrefixForURI(namespace); if (prefix == null && queryModule != null) { // queryModule can be null when optimizing a query fragment NamespaceResolver resolver = queryModule.getNamespaceResolver(); Iterator<String> prefixes = resolver.iteratePrefixes(); while (prefixes.hasNext()) { String p = prefixes.next(); if (namespace.equals(resolver.getURIForPrefix(p, true))) { prefix = p; break; } } } if (prefix != null) { namespaceDeclarations.put(prefix, namespace); } else { for (Map.Entry<String, String> ns : namespaceDeclarations.entrySet()) { if (ns.getValue().equals(namespace)) return ns.getKey(); } // this will happen if queryModule is null; it's actually ok in the only known case, which // is when we translate fragments while checking for document ordering (in which case the // exactitude of the QName translation is irrelevant). prefix = ""; } return prefix; }
public void open() throws XPathException { NamePool pool = getNamePool(); resultSequence = pool.allocate("result", RESULT_NS, "sequence"); resultDocument = pool.allocate("result", RESULT_NS, "document"); resultElement = pool.allocate("result", RESULT_NS, "element"); resultAttribute = pool.allocate("result", RESULT_NS, "attribute"); resultText = pool.allocate("result", RESULT_NS, "text"); resultComment = pool.allocate("result", RESULT_NS, "comment"); resultPI = pool.allocate("result", RESULT_NS, "processing-instruction"); resultNamespace = pool.allocate("result", RESULT_NS, "namespace"); resultAtomicValue = pool.allocate("result", RESULT_NS, "atomic-value"); xsiType = pool.allocate("xsi", NamespaceConstant.SCHEMA_INSTANCE, "type"); out.open(); out.startDocument(0); out.startElement(resultSequence, StandardNames.XS_UNTYPED, 0, 0); out.namespace(pool.allocateNamespaceCode("result", RESULT_NS), 0); out.namespace(pool.allocateNamespaceCode("xs", NamespaceConstant.SCHEMA), 0); out.namespace(pool.allocateNamespaceCode("xsi", NamespaceConstant.SCHEMA_INSTANCE), 0); out.startContent(); }
/** * Handle a namespace */ public void namespace(int namespaceCode, int properties) throws XPathException { int nc = newPool.allocateNamespaceCode(oldPool.getPrefixFromNamespaceCode(namespaceCode), oldPool.getURIFromNamespaceCode(namespaceCode)); nextReceiver.namespace(nc, properties); }
/** * Get the display form of a name (the QName), given its name code or fingerprint * * @param nameCode the integer name code or fingerprint of a name in the name pool * @return the corresponding lexical QName (if a fingerprint was supplied, this will * simply be the local name) */ public String getDisplayName(int nameCode) { return getStructuredQName(nameCode).getDisplayName(); }
/** * Get the prefix part of the name of this node. This is the name before the ":" if any. * @return the prefix part of the name. For an unnamed node, return null. */ public String getPrefix() { int code = tree.attCode[nodeNr]; if (NamePool.getPrefixIndex(code) == 0) return ""; return tree.getNamePool().getPrefix(code); }
/** * Method to support the element-available() function * @param uri the namespace URI * @param localName the local Name * @return true if an extension element of this name is recognized */ public boolean isElementAvailable(String uri, String localName) { int fingerprint = namePool.getFingerprint(uri, localName); if (uri.equals(NamespaceConstant.XSLT)) { if (fingerprint==-1) return false; // all names are pre-registered StyleElement e = makeXSLElement(fingerprint); if (e!=null) return e.isInstruction(); } if (uri.equals(NamespaceConstant.SAXON)) { if (fingerprint==-1) return false; // all names are pre-registered StyleElement e = makeSaxonElement(fingerprint); if (e!=null) return e.isInstruction(); } if (!allowExtensions) { // extension elements are disabled return false; } short uriCode = namePool.getCodeForURI(uri); ExtensionElementFactory factory = getFactory(uriCode); if (factory==null) return false; Class actualClass = factory.getExtensionClass(localName); return (actualClass != null); }
/** * Notify a namespace prefix to URI binding */ public void startPrefixMapping(String prefix, String uri) throws SAXException { //System.err.println("StartPrefixMapping " + prefix + "=" + uri); if (prefix.equals("xmlns")) { // the binding xmlns:xmlns="http://www.w3.org/2000/xmlns/" // should never be reported, but it's been known to happen return; } if (namespacesUsed >= namespaces.length) { int[] n2 = new int[namespacesUsed * 2]; System.arraycopy(namespaces, 0, n2, 0, namespacesUsed); namespaces = n2; } namespaces[namespacesUsed++] = pool.allocateNamespaceCode(prefix, uri); }
/** * Extract the list of CDATA elements from the output properties * @param details the output properties * @return an array of integer fingerprints of the element names in the cdata-section-elements property */ private int[] getCdataElements(Properties details) { String cdata = details.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS); if (cdata==null) { // this doesn't happen, but there's no harm allowing for it return new int[0]; } // first count the number of names in the list int count=0; StringTokenizer st1 = new StringTokenizer(cdata, " \t\n\r", false); while (st1.hasMoreTokens()) { st1.nextToken(); count++; } int[] array = new int[count]; count = 0; StringTokenizer st2 = new StringTokenizer(cdata, " \t\n\r", false); while (st2.hasMoreTokens()) { String expandedName = st2.nextToken(); array[count++] = getNamePool().allocateClarkName(expandedName); } return array; }
if (decl == null) { if (warnings) { visitor.issueWarning("Element " + config.getNamePool().getEQName(outermostElementName) + " is not declared in the schema", getLocation()); if (schemaType == null) { if (warnings) { StructuredQName childElement = getConfiguration().getNamePool().getStructuredQName(childfp); String message = "The complex type " + contentType.getDescription() + " does not allow a child element named " + getDiagnosticName(childElement, env); while (kids.hasNext()) { int kid = kids.next(); StructuredQName sq = getConfiguration().getNamePool().getStructuredQName(kid); if (sq.getLocalPart().equals(childElement.getLocalPart()) && kid != childfp) { message += ". Perhaps the namespace is " + StructuredQName childElement = getConfiguration().getNamePool().getStructuredQName(childfp); visitor.issueWarning( "The complex type " + contentType.getDescription() +