protected void compileContent(Compilation exec, ComponentDeclaration decl, SimpleNodeConstructor inst, Expression separator) throws XPathException { if (separator == null) { separator = new StringLiteral(StringValue.SINGLE_SPACE); } try { if (select == null) { select = compileSequenceConstructor(exec, decl, true); } select = makeSimpleContentConstructor(select, separator, getStaticContext()); inst.setSelect(select); } catch (XPathException err) { compileError(err); } }
public void validate(ComponentDeclaration decl) throws XPathException { if (select != null && hasChildNodes()) { String errorCode = getErrorCodeForSelectPlusContent(); compileError("An " + getDisplayName() + " element with a select attribute must be empty", errorCode); } AxisIterator kids = iterateAxis(AxisInfo.CHILD); NodeInfo first = kids.next(); if (select == null) { if (first == null) { // there are no child nodes and no select attribute //stringValue = ""; select = new StringLiteral(StringValue.EMPTY_STRING); select.setRetainedStaticContext(makeRetainedStaticContext()); } else { if (kids.next() == null && !isExpandingText()) { // there is exactly one child node if (first.getNodeKind() == Type.TEXT) { // it is a text node: optimize for this case select = new StringLiteral(first.getStringValue()); select.setRetainedStaticContext(makeRetainedStaticContext()); } } } } }
/** * Method for use by subclasses (processing-instruction and namespace) that take * a name and a select attribute * * @return the expression defining the name attribute * @throws XPathException if an error is detected */ protected Expression prepareAttributesNameAndSelect() throws XPathException { Expression name = null; String nameAtt = null; String selectAtt = null; AttributeCollection atts = getAttributeList(); for (int a = 0; a < atts.getLength(); a++) { String f = atts.getQName(a); if (f.equals("name")) { nameAtt = Whitespace.trim(atts.getValue(a)); name = makeAttributeValueTemplate(nameAtt, a); } else if (f.equals("select")) { selectAtt = atts.getValue(a); select = makeExpression(selectAtt, a); } else { checkUnknownAttribute(atts.getNodeName(a)); } } if (nameAtt == null) { reportAbsence("name"); } return name; }
public void validate(ComponentDeclaration decl) throws XPathException { if (select != null && hasChildNodes()) { String errorCode = getErrorCodeForSelectPlusContent(); compileError("An " + getDisplayName() + " element with a select attribute must be empty", errorCode); } AxisIterator kids = iterateAxis(AxisInfo.CHILD); NodeInfo first = kids.next(); if (select == null) { if (first == null) { // there are no child nodes and no select attribute //stringValue = ""; select = new StringLiteral(StringValue.EMPTY_STRING); select.setRetainedStaticContext(makeRetainedStaticContext()); } else { if (kids.next() == null && !isExpandingText()) { // there is exactly one child node if (first.getNodeKind() == Type.TEXT) { // it is a text node: optimize for this case select = new StringLiteral(first.getStringValue()); select.setRetainedStaticContext(makeRetainedStaticContext()); } } } } }
/** * Method for use by subclasses (processing-instruction and namespace) that take * a name and a select attribute * * @return the expression defining the name attribute * @throws XPathException if an error is detected */ protected Expression prepareAttributesNameAndSelect() throws XPathException { Expression name = null; String nameAtt = null; String selectAtt = null; AttributeCollection atts = getAttributeList(); for (int a = 0; a < atts.getLength(); a++) { String f = atts.getQName(a); if (f.equals("name")) { nameAtt = Whitespace.trim(atts.getValue(a)); name = makeAttributeValueTemplate(nameAtt, a); } else if (f.equals("select")) { selectAtt = atts.getValue(a); select = makeExpression(selectAtt, a); } else { checkUnknownAttribute(atts.getNodeName(a)); } } if (nameAtt == null) { reportAbsence("name"); } return name; }
protected void compileContent(Compilation exec, ComponentDeclaration decl, SimpleNodeConstructor inst, Expression separator) throws XPathException { if (separator == null) { separator = new StringLiteral(StringValue.SINGLE_SPACE); } try { if (select == null) { select = compileSequenceConstructor(exec, decl, true); } select = makeSimpleContentConstructor(select, separator, getStaticContext()); inst.setSelect(select); } catch (XPathException err) { compileError(err); } }