/** * Make a NameTest, using the static context for namespace resolution * * @param nodeType the type of node required (identified by a constant in * class Type) * @param qname the lexical QName of the required node * @param useDefault true if the default namespace should be used when * the QName is unprefixed * @throws XPathException if the QName is invalid * @return a NameTest, representing a pattern that tests for a node of a * given node kind and a given name */ public NameTest makeNameTest(short nodeType, String qname, boolean useDefault) throws XPathException { int nameCode = makeNameCode(qname, useDefault); return new NameTest(nodeType, nameCode, env.getNamePool()); }
/** * Make a NameTest, using the static context for namespace resolution * * @param nodeType the type of node required (identified by a constant in * class Type) * @param qname the lexical QName of the required node * @param useDefault true if the default namespace should be used when * the QName is unprefixed * @throws XPathException if the QName is invalid * @return a NameTest, representing a pattern that tests for a node of a * given node kind and a given name */ public NameTest makeNameTest(short nodeType, String qname, boolean useDefault) throws XPathException { int nameCode = makeNameCode(qname, useDefault); return new NameTest(nodeType, nameCode, env.getNamePool()); }
/** * Get the value of a given attribute of this node * @param fingerprint The fingerprint of the attribute name * @return the attribute value if it exists or null if not */ public String getAttributeValue(int fingerprint) { NameTest test = new NameTest(Type.ATTRIBUTE, fingerprint, getNamePool()); AxisIterator iterator = iterateAxis(Axis.ATTRIBUTE, test); NodeInfo attribute = (NodeInfo)iterator.next(); if (attribute == null) { return null; } else { return attribute.getStringValue(); } }
/** * Generate an equivalent NameTest * @return a NameTest that matches the same node kind and name */ public NameTest getEquivalentNameTest() { return new NameTest(origin.getNodeKind(), origin.getURI(), origin.getLocalPart(), origin.getConfiguration().getNamePool()); }
/** * Generate an equivalent NameTest * @return a NameTest that matches the same node kind and name */ public NameTest getEquivalentNameTest() { return new NameTest(origin.getNodeKind(), origin.getURI(), origin.getLocalPart(), origin.getConfiguration().getNamePool()); }
private WithParam[] loadWithParams(NodeInfo element, Expression parent, boolean needTunnel) throws XPathException { List<WithParam> wps = new ArrayList<>(4); NodeInfo wpElement; AxisIterator iterator = element.iterateAxis(AxisInfo.CHILD, new NameTest(Type.ELEMENT, NamespaceConstant.SAXON_XSLT_EXPORT, "withParam", config.getNamePool())); while ((wpElement = iterator.next()) != null) { String flags = wpElement.getAttributeValue("", "flags"); boolean isTunnel = flags != null && flags.contains("t"); if (needTunnel == isTunnel) { WithParam wp = new WithParam(); wp.setVariableQName(getQNameAttribute(wpElement, "name")); wp.setSelectExpression(parent, getFirstChildExpression(wpElement)); wp.setRequiredType(parseSequenceType(wpElement, "as")); wp.setTypeChecked(flags != null && flags.contains("c")); wps.add(wp); } } return wps.toArray(new WithParam[0]); }
@Override public void markNamespaceNode(NodeInfo origin) { NodeInfo element = builder.getCurrentParentNode(); NamePool pool = builder.getConfiguration().getNamePool(); String prefix = origin.getLocalPart(); markedNode = element.iterateAxis( AxisInfo.NAMESPACE, new NameTest(Type.NAMESPACE, "", prefix, pool)).next(); mark = -1; }
public void attribute(NodeName name, SimpleType typeCode, CharSequence value, Location locationId, int properties) throws XPathException { super.attribute(name, typeCode, value, locationId, properties); if (mark == Type.ATTRIBUTE) { NodeInfo element = builder.getCurrentParentNode(); markedNode = element.iterateAxis( AxisInfo.ATTRIBUTE, new NameTest(Type.ATTRIBUTE, name, builder.getConfiguration().getNamePool())).next(); mark = -1; } }
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) { if (pathMapNodeSet == null) { ContextItemExpression cie = new ContextItemExpression(); pathMapNodeSet = new PathMap.PathMapNodeSet(pathMap.makeNewRoot(cie)); } return pathMapNodeSet.createArc(AxisInfo.ATTRIBUTE, new NameTest(Type.ATTRIBUTE, attributeName, getConfiguration().getNamePool())); }
/** * Retrieves an <code>Attr</code> node by local name and namespace URI. * This implementation does not expose namespace nodes as attributes. * * @param namespaceURI The namespace URI of the attribute to retrieve. * @param localName The local name of the attribute to retrieve. * @return The <code>Attr</code> node with the specified attribute local * name and namespace URI or <code>null</code> if there is no such * attribute. * @since DOM Level 2 */ public Attr getAttributeNodeNS(String namespaceURI, String localName) { NamePool pool = node.getConfiguration().getNamePool(); NameTest test = new NameTest(Type.ATTRIBUTE, namespaceURI, localName, pool); AxisIterator atts = node.iterateAxis(AxisInfo.ATTRIBUTE, test); return (Attr) wrap(atts.next()); }
@Override public void markNamespaceNode(NodeInfo origin) { NodeInfo element = builder.getCurrentParentNode(); NamePool pool = builder.getConfiguration().getNamePool(); String prefix = origin.getLocalPart(); markedNode = element.iterateAxis( AxisInfo.NAMESPACE, new NameTest(Type.NAMESPACE, "", prefix, pool)).next(); mark = -1; }
/** * Retrieves an <code>Attr</code> node by local name and namespace URI. * This implementation does not expose namespace nodes as attributes. * @param namespaceURI The namespace URI of the attribute to retrieve. * @param localName The local name of the attribute to retrieve. * @return The <code>Attr</code> node with the specified attribute local * name and namespace URI or <code>null</code> if there is no such * attribute. * @since DOM Level 2 */ public Attr getAttributeNodeNS(String namespaceURI, String localName) { NamePool pool = node.getNamePool(); int fingerprint = pool.getFingerprint((namespaceURI==null ? "" : namespaceURI), localName); if (fingerprint==-1) return null; NameTest test = new NameTest(Type.ATTRIBUTE, fingerprint, pool); AxisIterator atts = node.iterateAxis(Axis.ATTRIBUTE, test); return (Attr)wrap((NodeInfo)atts.next()); }
public PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet) { if (pathMapNodeSet == null) { ContextItemExpression cie = new ContextItemExpression(); pathMapNodeSet = new PathMap.PathMapNodeSet(pathMap.makeNewRoot(cie)); } return pathMapNodeSet.createArc(AxisInfo.ATTRIBUTE, new NameTest(Type.ATTRIBUTE, attributeName, getConfiguration().getNamePool())); }
public void attribute(NodeName name, SimpleType typeCode, CharSequence value, Location locationId, int properties) throws XPathException { super.attribute(name, typeCode, value, locationId, properties); if (mark == Type.ATTRIBUTE) { NodeInfo element = builder.getCurrentParentNode(); markedNode = element.iterateAxis( AxisInfo.ATTRIBUTE, new NameTest(Type.ATTRIBUTE, name, builder.getConfiguration().getNamePool())).next(); mark = -1; } }
/** * Retrieves an <code>Attr</code> node by local name and namespace URI. * This implementation does not expose namespace nodes as attributes. * * @param namespaceURI The namespace URI of the attribute to retrieve. * @param localName The local name of the attribute to retrieve. * @return The <code>Attr</code> node with the specified attribute local * name and namespace URI or <code>null</code> if there is no such * attribute. * @since DOM Level 2 */ public Attr getAttributeNodeNS(String namespaceURI, String localName) { NamePool pool = node.getConfiguration().getNamePool(); NameTest test = new NameTest(Type.ATTRIBUTE, namespaceURI, localName, pool); AxisIterator atts = node.iterateAxis(AxisInfo.ATTRIBUTE, test); return (Attr) wrap(atts.next()); }
public void namespace(/*@NotNull*/ NamespaceBindingSet namespaceBindings, int properties) throws XPathException { super.namespace(namespaceBindings, properties); if (mark == Type.NAMESPACE) { for (NamespaceBinding ns : namespaceBindings) { NodeInfo element = builder.getCurrentParentNode(); NamePool pool = builder.getConfiguration().getNamePool(); String prefix = ns.getPrefix(); markedNode = element.iterateAxis( AxisInfo.NAMESPACE, new NameTest(Type.NAMESPACE, "", prefix, pool)).next(); mark = -1; } } }
private void readCharacterMaps(NodeInfo packageElement) throws XPathException { StylesheetPackage pack = packStack.peek(); NodeInfo charMapElement; AxisIterator iterator = packageElement.iterateAxis(AxisInfo.CHILD, new NameTest(Type.ELEMENT, NamespaceConstant.SAXON_XSLT_EXPORT, "charMap", config.getNamePool())); while ((charMapElement = iterator.next()) != null) { StructuredQName mapName = getQNameAttribute(charMapElement, "name"); NodeInfo mappingElement; AxisIterator iterator1 = charMapElement.iterateAxis(AxisInfo.CHILD, new NameTest(Type.ELEMENT, NamespaceConstant.SAXON_XSLT_EXPORT, "m", config.getNamePool())); IntHashMap<String> map = new IntHashMap<>(); while ((mappingElement = iterator1.next()) != null) { int c = getIntegerAttribute(mappingElement, "c"); String s = mappingElement.getAttributeValue("", "s"); map.put(c, s); } CharacterMap characterMap = new CharacterMap(mapName, map); pack.getCharacterMapIndex().putCharacterMap(mapName, characterMap); } }
private void readCharacterMaps(NodeInfo packageElement) { StylesheetPackage pack = packStack.peek(); NodeInfo charMapElement; AxisIterator iterator = packageElement.iterateAxis(AxisInfo.CHILD, new NameTest(Type.ELEMENT, NamespaceConstant.SAXON_XSLT_EXPORT, "charMap", config.getNamePool())); while ((charMapElement = iterator.next()) != null) { StructuredQName mapName = getQNameAttribute(charMapElement, "name"); NodeInfo mappingElement; AxisIterator iterator1 = charMapElement.iterateAxis(AxisInfo.CHILD, new NameTest(Type.ELEMENT, NamespaceConstant.SAXON_XSLT_EXPORT, "m", config.getNamePool())); IntHashMap<String> map = new IntHashMap<>(); while ((mappingElement = iterator1.next()) != null) { int c = getIntegerAttribute(mappingElement, "c"); String s = mappingElement.getAttributeValue("", "s"); map.put(c, s); } CharacterMap characterMap = new CharacterMap(mapName, map); pack.getCharacterMapIndex().putCharacterMap(mapName, characterMap); } }
public void namespace(/*@NotNull*/ NamespaceBindingSet namespaceBindings, int properties) throws XPathException { super.namespace(namespaceBindings, properties); if (mark == Type.NAMESPACE) { for (NamespaceBinding ns : namespaceBindings) { NodeInfo element = builder.getCurrentParentNode(); NamePool pool = builder.getConfiguration().getNamePool(); String prefix = ns.getPrefix(); markedNode = element.iterateAxis( AxisInfo.NAMESPACE, new NameTest(Type.NAMESPACE, "", prefix, pool)).next(); mark = -1; } } }
public NodeInfo getMarkedNode() { if (markedNodeNr != -1) { return builder.getTree().getNode(markedNodeNr); } else if (markedAttribute != -1) { return builder.getTree().getAttributeNode(markedAttribute); } else if (markedNamespace != -1) { NamespaceBinding nscode = builder.getTree().namespaceBinding[markedNamespace]; NamePool pool = builder.getConfiguration().getNamePool(); String prefix = nscode.getPrefix(); NodeInfo parent = builder.getTree().getNode(builder.getTree().namespaceParent[markedNamespace]); NameTest test = new NameTest(Type.NAMESPACE, "", prefix, pool); AxisIterator iter = parent.iterateAxis(AxisInfo.NAMESPACE, test); return iter.next(); } else { return null; } } }