/** * Get the name of the node. Returns null for an unnamed node * * @return the name of the node */ @Override public NodeName getNodeName() { return new NoNamespaceName(name); }
/** * Get the name of the node. Returns null for an unnamed node * * @return the name of the node */ @Override public NodeName getNodeName() { return new NoNamespaceName(name); }
public NodeName evaluateNodeName(XPathContext context) throws XPathException { String expandedName = evaluateName(context); return new NoNamespaceName(expandedName); }
public NodeName evaluateNodeName(XPathContext context) throws XPathException { String prefix = evaluatePrefix(context); return new NoNamespaceName(prefix); }
public NodeName evaluateNodeName(XPathContext context) throws XPathException { String expandedName = evaluateName(context); return new NoNamespaceName(expandedName); }
public NodeName evaluateNodeName(XPathContext context) throws XPathException { String prefix = evaluatePrefix(context); return new NoNamespaceName(prefix); }
/** * Convert a lexical QName to a NodeName object encapsulating the prefix, local part, and namespace URI * @param name the lexical QName * @param useDefaultNS true for an element name, false for an attribute name * @return the expanded node name */ private NodeName getNodeName(String name, boolean useDefaultNS) { int colon = name.indexOf(':'); if (colon < 0) { if (useDefaultNS) { String uri = getUriForPrefix(""); if (!uri.isEmpty()) { return new FingerprintedQName("", uri, name); } } return new NoNamespaceName(name); } else { String prefix = name.substring(0, colon); String uri = getUriForPrefix(prefix); if (uri == null) { throw new IllegalStateException("Prefix " + prefix + " is not bound to any namespace"); } return new FingerprintedQName(prefix, uri, name.substring(colon+1)); } }
/** * Output an attribute node * * @param name the name of the attribute * @param value the value of the attribute */ public void emitAttribute(String name, String value) { if (value != null) { if (name.equals("module")) { value = truncatedModuleName(value); } try { receiver.attribute(new NoNamespaceName(name), BuiltInAtomicType.UNTYPED_ATOMIC, value, ExplicitLocation.UNKNOWN_LOCATION, 0); } catch (XPathException err) { err.printStackTrace(); throw new InternalError(err.getMessage()); } } }
/** * Output an attribute node * * @param name the name of the attribute * @param value the value of the attribute */ public void emitAttribute(String name, String value) { if (value != null) { if (name.equals("module")) { value = truncatedModuleName(value); } try { receiver.attribute(new NoNamespaceName(name), BuiltInAtomicType.UNTYPED_ATOMIC, value, ExplicitLocation.UNKNOWN_LOCATION, 0); } catch (XPathException err) { err.printStackTrace(); throw new InternalError(err.getMessage()); } } }
/** * Processing Instruction */ public void processingInstruction(String target, CharSequence data, Location locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } checkItemType(NodeKindTest.PROCESSING_INSTRUCTION, nodeSupplier(Type.PROCESSING_INSTRUCTION, new NoNamespaceName(target), data), locationId); } nextReceiver.processingInstruction(target, data, locationId, properties); }
/** * Processing Instruction */ public void processingInstruction(String target, CharSequence data, Location locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } checkItemType(NodeKindTest.PROCESSING_INSTRUCTION, nodeSupplier(Type.PROCESSING_INSTRUCTION, new NoNamespaceName(target), data), locationId); } nextReceiver.processingInstruction(target, data, locationId, properties); }
private void processShadowAttributes(NodeName elemName, Location location, URI baseUri) throws XPathException { AttributeCollection atts = startTag.getAllAttributes(); for (int a=0; a<atts.getLength(); a++) { String local = atts.getLocalName(a); String uri = atts.getURI(a); if (local.startsWith("_") && (uri.isEmpty() || uri.equals(NamespaceConstant.SAXON)) && local.length() >= 2) { String value = atts.getValue(a); AttributeLocation attLocation = new AttributeLocation(elemName.getStructuredQName(), atts.getNodeName(a).getStructuredQName(), location); String newValue = processShadowAttribute(value, baseUri.toString(), attLocation); String plainName = local.substring(1); NodeName newName = uri.isEmpty() ? new NoNamespaceName(plainName) : new FingerprintedQName(atts.getPrefix(a), NamespaceConstant.SAXON, plainName); // if a corresponding attribute exists with no underscore, overwrite it. The attribute() // method ensures that the shadow attribute won't be passed down the pipeline. // Otherwise overwrite the shadow attribute itself. int index = atts.getIndex("", plainName); if (index == -1) { index = a; } ((AttributeCollectionImpl)atts).setAttribute( index, newName, BuiltInAtomicType.UNTYPED_ATOMIC, newValue, atts.getLocation(a), 0); } } }
private int _startElement(String name) { //System.err.println("start " + name + " at " + new XPathException("").getStackTrace().length); try { if (inStartTag) { receiver.startContent(); inStartTag = false; } NodeName nodeName; if (defaultNamespace == null) { nodeName = new NoNamespaceName(name); } else { nodeName = new FingerprintedQName("", defaultNamespace, name); } receiver.startElement(nodeName, Untyped.getInstance(), ExplicitLocation.UNKNOWN_LOCATION, 0); if (nextRole != null) { emitAttribute("role", nextRole); nextRole = null; } } catch (XPathException err) { err.printStackTrace(); throw new InternalError(err.getMessage()); } inStartTag = true; return depth++; }
@Override public void processingInstruction(String target, CharSequence data, Location locationId, int properties) throws XPathException { if (inStartTag) { startContent(); } if (level == 0) { Orphan o = new Orphan(getConfiguration()); o.setNodeName(new NoNamespaceName(target)); o.setNodeKind(Type.PROCESSING_INSTRUCTION); o.setStringValue(data); write(o); } else { outputter.processingInstruction(target, data, locationId, properties); } previousAtomic = false; }
@Override public void processingInstruction(String target, CharSequence data, Location locationId, int properties) throws XPathException { if (inStartTag) { startContent(); } if (level == 0) { Orphan o = new Orphan(getConfiguration()); o.setNodeName(new NoNamespaceName(target)); o.setNodeKind(Type.PROCESSING_INSTRUCTION); o.setStringValue(data); write(o); } else { outputter.processingInstruction(target, data, locationId, properties); } previousAtomic = false; }
@Override public void namespace(NamespaceBindingSet namespaceBindings, int properties) throws XPathException { if (level == 0) { for (NamespaceBinding ns : namespaceBindings) { Orphan o = new Orphan(getConfiguration()); o.setNodeKind(Type.NAMESPACE); o.setNodeName(new NoNamespaceName(ns.getPrefix())); o.setStringValue(ns.getURI()); append(o, ExplicitLocation.UNKNOWN_LOCATION, ReceiverOptions.ALL_NAMESPACES); } } else { outputter.namespace(namespaceBindings, properties); } previousAtomic = false; }
@Override public void namespace(NamespaceBindingSet namespaceBindings, int properties) throws XPathException { if (level == 0) { for (NamespaceBinding ns : namespaceBindings) { Orphan o = new Orphan(getConfiguration()); o.setNodeKind(Type.NAMESPACE); o.setNodeName(new NoNamespaceName(ns.getPrefix())); o.setStringValue(ns.getURI()); append(o, ExplicitLocation.UNKNOWN_LOCATION, ReceiverOptions.ALL_NAMESPACES); } } else { outputter.namespace(namespaceBindings, properties); } previousAtomic = false; }
/** * Make a FingerprintedQName, using the static context for namespace resolution * * @param qname The name as written, in the form "[prefix:]localname"; alternatively, a QName in * Clark format ({uri}local) * @param useDefault Defines the action when there is no prefix. If * true, use the default namespace URI for element names. If false, * use no namespace URI (as for attribute names). * @return the fingerprinted QName * @throws XPathException if the name is invalid, or the prefix * undeclared */ /*@NotNull*/ public final NodeName makeNodeName(String qname, boolean useDefault) throws XPathException { StructuredQName sq = makeStructuredQNameSilently(qname, useDefault ? env.getDefaultElementNamespace() : ""); String prefix = sq.getPrefix(); String uri = sq.getURI(); String local = sq.getLocalPart(); if (uri.isEmpty()) { int fp = env.getConfiguration().getNamePool().allocateFingerprint("", qname); return new NoNamespaceName(qname, fp); } else { int fp = env.getConfiguration().getNamePool().allocateFingerprint(uri, local); return new FingerprintedQName(prefix, uri, local, fp); } }
private synchronized void init(Configuration config, boolean schemaAware) throws XPathException { resultName = new FingerprintedQName("", NamespaceConstant.FN, "analyze-string-result"); nonMatchName = new FingerprintedQName("", NamespaceConstant.FN, "non-match"); matchName = new FingerprintedQName("", NamespaceConstant.FN, "match"); groupName = new FingerprintedQName("", NamespaceConstant.FN, "group"); groupNrName = new NoNamespaceName("nr"); if (schemaAware) { resultType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "analyze-string-result-type")); nonMatchType = BuiltInAtomicType.STRING; matchType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "match-type")); groupType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "group-type")); groupNrType = BuiltInAtomicType.POSITIVE_INTEGER; if (resultType == null || matchType == null || groupType == null) { throw new XPathException("Schema for analyze-string has not been successfully loaded"); } } }
private synchronized void init(Configuration config, boolean schemaAware) throws XPathException { resultName = new FingerprintedQName("", NamespaceConstant.FN, "analyze-string-result"); nonMatchName = new FingerprintedQName("", NamespaceConstant.FN, "non-match"); matchName = new FingerprintedQName("", NamespaceConstant.FN, "match"); groupName = new FingerprintedQName("", NamespaceConstant.FN, "group"); groupNrName = new NoNamespaceName("nr"); if (schemaAware) { resultType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "analyze-string-result-type")); nonMatchType = BuiltInAtomicType.STRING; matchType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "match-type")); groupType = config.getSchemaType(new StructuredQName("", NamespaceConstant.FN, "group-type")); groupNrType = BuiltInAtomicType.POSITIVE_INTEGER; if (resultType == null || matchType == null || groupType == null) { throw new XPathException("Schema for analyze-string has not been successfully loaded"); } } }