@Override public int isSpacePreserving(NodeName nodeName, SchemaType schemaType) { return elementTest.test(new QName(nodeName.getStructuredQName())) ? Stripper.ALWAYS_STRIP : Stripper.ALWAYS_PRESERVE; }
@Override public int isSpacePreserving(NodeName nodeName, SchemaType schemaType) { return elementTest.test(new QName(nodeName.getStructuredQName())) ? Stripper.ALWAYS_STRIP : Stripper.ALWAYS_PRESERVE; }
/** * Test whether the NameTest matches a given QName * * @param qname the QName to be matched * @return true if the name matches */ public boolean matches(StructuredQName qname) { return NameOfNode.makeName(origin).getStructuredQName().equals(qname); }
/** * Get an iterator over all the properties available. The values returned by the iterator * will be of type String, and each string can be supplied as input to the getProperty() * method to retrieve the value of the property. */ public Iterator<String> getProperties() { List<String> list = new ArrayList<>(10); iterateAxis(AxisInfo.ATTRIBUTE).forEach(a -> list.add(NameOfNode.makeName(a).getStructuredQName().getClarkName()) ); return list.iterator(); }
/** * Test whether the NameTest matches a given QName * * @param qname the QName to be matched * @return true if the name matches */ public boolean matches(StructuredQName qname) { return NameOfNode.makeName(origin).getStructuredQName().equals(qname); }
/** * Get an iterator over all the properties available. The values returned by the iterator * will be of type String, and each string can be supplied as input to the getProperty() * method to retrieve the value of the property. */ public Iterator<String> getProperties() { List<String> list = new ArrayList<>(10); iterateAxis(AxisInfo.ATTRIBUTE).forEach(a -> list.add(NameOfNode.makeName(a).getStructuredQName().getClarkName()) ); return list.iterator(); }
@Override public String toString() { return "<" + elementName.getStructuredQName().getDisplayName() + " {" + getContentExpression().toString() + "}/>"; }
@Override public String toShortString() { return "<" + elementName.getStructuredQName().getDisplayName() + " {" + getContentExpression().toShortString() + "}/>"; }
@Override public String toShortString() { return "<" + elementName.getStructuredQName().getDisplayName() + " {" + getContentExpression().toShortString() + "}/>"; }
@Override public String toString() { return "<" + elementName.getStructuredQName().getDisplayName() + " {" + getContentExpression().toString() + "}/>"; }
public String toString() { switch (origin.getNodeKind()) { case Type.ELEMENT: return "element(" + NameOfNode.makeName(origin).getStructuredQName().getEQName() + ")"; case Type.ATTRIBUTE: return "attribute(" + NameOfNode.makeName(origin).getStructuredQName().getEQName() + ")"; case Type.PROCESSING_INSTRUCTION: return "processing-instruction(" + origin.getLocalPart() + ')'; case Type.NAMESPACE: return "namespace-node(" + origin.getLocalPart() + ')'; case Type.COMMENT: return "comment()"; case Type.DOCUMENT: return "document-node()"; case Type.TEXT: return "text()"; default: return "***"; } }
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 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); if (local.startsWith("_") && atts.getURI(a).equals("") && 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 = new NoNamespaceName(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); } } }
public String toString() { switch (origin.getNodeKind()) { case Type.ELEMENT: return "element(" + NameOfNode.makeName(origin).getStructuredQName().getEQName() + ")"; case Type.ATTRIBUTE: return "attribute(" + NameOfNode.makeName(origin).getStructuredQName().getEQName() + ")"; case Type.PROCESSING_INSTRUCTION: return "processing-instruction(" + origin.getLocalPart() + ')'; case Type.NAMESPACE: return "namespace-node(" + origin.getLocalPart() + ')'; case Type.COMMENT: return "comment()"; case Type.DOCUMENT: return "document-node()"; case Type.TEXT: return "text()"; default: return "***"; } }
/** * Make an attribute value template in the context of this stylesheet element * * @param expression the source text of the attribute value template * @return a compiled XPath expression that computes the value of the attribute (including * concatenating the results of embedded expressions with any surrounding fixed text) */ protected Expression makeAttributeValueTemplate(String expression, int attIndex) { StaticContext env = attIndex == -1 ? staticContext : getStaticContext(getAttributeList().getNodeName(attIndex).getStructuredQName()); if (attIndex >= 0) { StructuredQName attName = getAttributeList().getNodeName(attIndex).getStructuredQName(); env = getStaticContext(attName); } try { return AttributeValueTemplate.make(expression, env); } catch (XPathException err) { compileError(err); return new StringLiteral(expression); } }
/** * Make an attribute value template in the context of this stylesheet element * * @param expression the source text of the attribute value template * @return a compiled XPath expression that computes the value of the attribute (including * concatenating the results of embedded expressions with any surrounding fixed text) */ protected Expression makeAttributeValueTemplate(String expression, int attIndex) { StaticContext env = attIndex == -1 ? staticContext : getStaticContext(getAttributeList().getNodeName(attIndex).getStructuredQName()); if (attIndex >= 0) { StructuredQName attName = getAttributeList().getNodeName(attIndex).getStructuredQName(); env = getStaticContext(attName); } try { return AttributeValueTemplate.make(expression, env); } catch (XPathException err) { compileError(err); return new StringLiteral(expression); } }
public AbstractExpression exprFor (FixedElement element) { NodeName name = element.getElementName(); QName qname = qnameFor (name.getStructuredQName()); AbstractExpression content = exprFor (element.getContentExpression()); Namespace [] namespaces = namespacesFor (element.getActiveNamespaces()); return new ElementConstructor(qname, namespaces, content); }
public AbstractExpression exprFor (FixedAttribute attribute) { NodeName name = attribute.getAttributeName(); QName qname = qnameFor (name.getStructuredQName()); AttributeConstructor att = new AttributeConstructor( new LiteralExpression(qname.toString(), ValueType.STRING), exprFor (attribute.getContentExpression())); return att; }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void export(ExpressionPresenter out) throws XPathException { out.startElement("att", this); out.emitAttribute("name", nodeName.getDisplayName()); if (!nodeName.getStructuredQName().hasURI("")) { out.emitAttribute("nsuri", nodeName.getStructuredQName().getURI()); } if (getValidationAction() != Validation.SKIP && getValidationAction() != Validation.BY_TYPE) { out.emitAttribute("validation", Validation.toString(getValidationAction())); } if (getSchemaType() != null) { out.emitAttribute("type", getSchemaType().getStructuredQName()); } String flags = ""; if (isLocal()) { flags += "l"; } if (!flags.isEmpty()) { out.emitAttribute("flags", flags); } getSelect().export(out); out.endElement(); }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void export(ExpressionPresenter out) throws XPathException { out.startElement("att", this); out.emitAttribute("name", nodeName.getDisplayName()); if (!nodeName.getStructuredQName().hasURI("")) { out.emitAttribute("nsuri", nodeName.getStructuredQName().getURI()); } if (getValidationAction() != Validation.SKIP && getValidationAction() != Validation.BY_TYPE) { out.emitAttribute("validation", Validation.toString(getValidationAction())); } if (getSchemaType() != null) { out.emitAttribute("type", getSchemaType().getStructuredQName()); } String flags = ""; if (isLocal()) { flags += "l"; } if (!flags.isEmpty()) { out.emitAttribute("flags", flags); } getSelect().export(out); out.endElement(); }