public void validate() throws XPathException { if (validated) return; checkTopLevel(null); stackFrameMap = getConfiguration().makeSlotManager(); AxisIterator kids = iterateAxis(Axis.CHILD); while (true) { Item child = kids.next(); if (child == null) { break; } if (!(child instanceof XSLAttribute)) { compileError("Only xsl:attribute is allowed within xsl:attribute-set", "XTSE0010"); } } if (useAtt!=null) { // identify any attribute sets that this one refers to attributeSetElements = new ArrayList(5); useAttributeSets = getAttributeSets(useAtt, attributeSetElements); // check for circularity for (Iterator it=attributeSetElements.iterator(); it.hasNext();) { ((XSLAttributeSet)it.next()).checkCircularity(this); } } validated = true; }
/** * Check for circularity: specifically, check that this attribute set does not contain * a direct or indirect reference to the one supplied as a parameter * * @param origin the place from which the search started * @throws net.sf.saxon.trans.XPathException * if an error is found */ public void checkCircularity(XSLAttributeSet origin) throws XPathException { if (this == origin) { compileError("The definition of the attribute set is circular", "XTSE0720"); } else { if (!validated) { // if this attribute set isn't validated yet, we don't check it. // The circularity will be detected when the last attribute set in the cycle // gets validated return; } if (attributeSetElements != null) { for (ComponentDeclaration attributeSetElement : attributeSetElements) { XSLAttributeSet element = (XSLAttributeSet) attributeSetElement.getSourceElement(); element.checkCircularity(origin); if (streamable && !element.streamable) { compileError("Attribute-set is declared streamable but references a non-streamable attribute set " + element.getAttributeSetName().getDisplayName(), "XTSE3430"); } } } } }
/** * Get a name identifying the object of the expression, for example a function name, template name, * variable name, key name, element name, etc. This is used only where the name is known statically. * If there is no name, the value will be null. * * @return the name of the object declared in this element, if any */ public StructuredQName getObjectName() { StructuredQName o = super.getObjectName(); if (o == null) { try { prepareAttributes(); o = getObjectName(); } catch (XPathException err) { o = new StructuredQName("saxon", NamespaceConstant.SAXON, "badly-named-attribute-set"); setObjectName(o); } } return o; }
public void validate(ComponentDeclaration decl) throws XPathException { if (validated) { return; } checkTopLevel("XTSE0010", true); stackFrameMap = getConfiguration().makeSlotManager(); AxisIterator kids = iterateAxis(AxisInfo.CHILD); NodeInfo child; while ((child = kids.next()) != null) { if (child instanceof XSLAttribute) { if (visibility == Visibility.ABSTRACT) { compileError("An abstract attribute-set must contain no xsl:attribute instructions"); } } else { compileError("Only xsl:attribute is allowed within xsl:attribute-set", "XTSE0010"); } } if (useAtt != null) { if (visibility == Visibility.ABSTRACT) { compileError("An abstract attribute-set must have no @use-attribute-sets attribute"); } // identify any attribute sets that this one refers to useAttributeSetNames = getUsedAttributeSets(useAtt); } validated = true; }
/** * Check for circularity: specifically, check that this attribute set does not contain * a direct or indirect reference to the one supplied as a parameter * @param origin the place from which the search started */ public void checkCircularity(XSLAttributeSet origin) throws XPathException { if (this==origin) { compileError("The definition of the attribute set is circular", "XTSE0720"); useAttributeSets = null; } else { if (!validated) { // if this attribute set isn't validated yet, we don't check it. // The circularity will be detected when the last attribute set in the cycle // gets validated return; } if (attributeSetElements != null) { for (Iterator it=attributeSetElements.iterator(); it.hasNext();) { ((XSLAttributeSet)it.next()).checkCircularity(origin); } } } }
/** * Check the compatibility of this component with another component that it is overriding * * @param component the overridden component * @throws XPathException if the components are not compatible (differing signatures) */ public void checkCompatibility(Component component) throws XPathException { if (((AttributeSet)component.getActor()).isDeclaredStreamable() && !isDeclaredStreamable()) { compileError("The overridden attribute set is declared streamable, " + "so the overriding attribute set must also be declared streamable"); } }
public void prepareAttributes() throws XPathException { useAtt = null; AttributeCollection atts = getAttributeList(); for (int a=0; a<atts.getLength(); a++) { int nc = atts.getNameCode(a); String f = getNamePool().getClarkName(nc); if (f.equals(StandardNames.NAME)) { nameAtt = Whitespace.trim(atts.getValue(a)); } else if (f.equals(StandardNames.USE_ATTRIBUTE_SETS)) { useAtt = atts.getValue(a); } else { checkUnknownAttribute(nc); } } if (nameAtt==null) { reportAbsence("name"); setObjectName(new StructuredQName("", "", "attribute-set-error-name")); return; } try { setObjectName(makeQName(nameAtt)); } catch (NamespaceException err) { compileError(err.getMessage(), "XTSE0280"); setObjectName(new StructuredQName("", "", "attribute-set-error-name")); } catch (XPathException err) { compileError(err.getMessage(), "XTSE0280"); setObjectName(new StructuredQName("", "", "attribute-set-error-name")); } }
Expression body = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true); if (body == null) { body = Literal.makeEmptySequence(); ExpressionVisitor visitor = makeExpressionVisitor(); body = visitor.simplify(body); if (getConfiguration().isCompileWithTracing()) { TraceWrapper trace = new TraceInstruction(body, this); trace.setLocationId(allocateLocationId(getSystemId(), getLineNumber())); trace.setContainer(procedure); body = trace; procedure.setName(getObjectName()); procedure.setBody(body); procedure.setSystemId(getSystemId()); procedure.setLineNumber(getLineNumber()); procedure.setExecutable(exec); procedure.setStackFrameMap(stackFrameMap); } catch (XPathException e) { compileError(e);
String streamableAtt = null; AttributeCollection atts = getAttributeList(); visibilityAtt = Whitespace.trim(atts.getValue(a)); } else { checkUnknownAttribute(atts.getNodeName(a)); reportAbsence("name"); setObjectName(new StructuredQName("", "", "attribute-set-error-name")); return; visibility = Visibility.PRIVATE; } else { visibility = interpretVisibilityValue(visibilityAtt, ""); streamable = processStreamableAtt(streamableAtt); setObjectName(makeQName(nameAtt)); } catch (XPathException err) { setObjectName(new StructuredQName("", "", "attribute-set-error-name")); err.setLocation(new AttributeLocation(this, StructuredQName.fromClarkName("name"))); throw err;
if (isActionCompleted(ACTION_COMPILE)) { return; getPrincipalStylesheetModule().getAttributeSets(name, attributeSetElements); ((XSLAttributeSet) attributeSetElement.getSourceElement()).checkCircularity(this); for (ComponentDeclaration attributeSetElement : attributeSetElements) { if (!((XSLAttributeSet) attributeSetElement.getSourceElement()).streamable) { compileError("Attribute set is declared streamable, " + "but references an attribute set that is not declared streamable", "XTSE0730"); AxisIterator iter = iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT); while ((node = (XSLAttribute) iter.next()) != null) { Expression inst = node.compile(compilation, decl); inst.setRetainedStaticContext(makeRetainedStaticContext()); inst = inst.simplify(); if (compilation.getCompilerInfo().isCompileWithTracing()) { inst = makeTraceInstruction(this, inst); setActionCompleted(ACTION_COMPILE);
if (toplevel.get(i) instanceof XSLAttributeSet) { XSLAttributeSet t = (XSLAttributeSet)toplevel.get(i); if (t.getAttributeSetName().equals(fprint)) { list.add(t); found = true; for (int i = 0; i < list.size(); i++) { XSLAttributeSet aset = (XSLAttributeSet)list.get(i); aset.incrementReferenceCount(); array[i] = aset.getInstruction();
return new XSLAttribute(); case StandardNames.XSL_ATTRIBUTE_SET: return new XSLAttributeSet(); case StandardNames.XSL_CALL_TEMPLATE: return new XSLCallTemplate();
/** * Get the name of this attribute set * * @return the name of the attribute set, as a QName */ public StructuredQName getAttributeSetName() { return getObjectName(); }
/** * Get the corresponding Procedure object that results from the compilation of this * StylesheetProcedure */ public AttributeSet getActor() { return (AttributeSet)getPrincipalStylesheetModule().getStylesheetPackage().getComponent( new SymbolicName(StandardNames.XSL_ATTRIBUTE_SET, getObjectName())).getActor(); }
/** * Add an attribute set to the index * * @param decl the declaration of the attribute set object * @throws XPathException if an error occurs */ protected void indexAttributeSet(ComponentDeclaration decl) throws XPathException { //HashMap<SymbolicName, Component> componentIndex = stylesheetPackage.getComponentIndex(); XSLAttributeSet sourceAttributeSet = (XSLAttributeSet) decl.getSourceElement(); StructuredQName name = sourceAttributeSet.getAttributeSetName(); List<ComponentDeclaration> entries = attributeSetDeclarations.get(name); if (entries == null) { entries = new ArrayList<>(); attributeSetDeclarations.put(name, entries); } else { String thisVis = Whitespace.trim(sourceAttributeSet.getAttributeValue("", "visibility")); String firstVis = Whitespace.trim(entries.get(0).getSourceElement().getAttributeValue("", "visibility")); if (thisVis == null ? firstVis != null : !thisVis.equals(firstVis)) { throw new XPathException("Visibility attributes on attribute-sets sharing the same name must all be the same", "XTSE0010"); } } entries.add(0, decl); }
/** * Get the list of attribute-set declarations associated with a given QName. * This is used for xsl:element, xsl:copy, xsl:attribute-set, and on literal * result elements * * @param name the name of the required attribute set * @param list a list to hold the list of XSLAttributeSet elements in the stylesheet tree. */ protected void getAttributeSets(StructuredQName name, List<ComponentDeclaration> list) { // search for the named attribute set, using all of them if there are several with the // same name for (ComponentDeclaration decl : topLevel) { if (decl.getSourceElement() instanceof XSLAttributeSet) { XSLAttributeSet t = (XSLAttributeSet) decl.getSourceElement(); if (t.getAttributeSetName().equals(name)) { list.add(decl); } } } }
public void prepareAttributes() throws XPathException { useAtt = null; AttributeCollection atts = getAttributeList(); for (int a=0; a<atts.getLength(); a++) { int nc = atts.getNameCode(a); String f = getNamePool().getClarkName(nc); if (f.equals(StandardNames.NAME)) { nameAtt = Whitespace.trim(atts.getValue(a)); } else if (f.equals(StandardNames.USE_ATTRIBUTE_SETS)) { useAtt = atts.getValue(a); } else { checkUnknownAttribute(nc); } } if (nameAtt==null) { reportAbsence("name"); setObjectName(new StructuredQName("", "", "attribute-set-error-name")); return; } try { setObjectName(makeQName(nameAtt)); } catch (NamespaceException err) { compileError(err.getMessage(), "XTSE0280"); setObjectName(new StructuredQName("", "", "attribute-set-error-name")); } catch (XPathException err) { compileError(err.getMessage(), err.getErrorCodeLocalPart()); setObjectName(new StructuredQName("", "", "attribute-set-error-name")); } }
Expression body = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true); if (body == null) { body = Literal.makeEmptySequence(); ExpressionVisitor visitor = makeExpressionVisitor(); body = visitor.simplify(body); if (getConfiguration().isCompileWithTracing()) { TraceWrapper trace = new TraceInstruction(body, this); trace.setLocationId(allocateLocationId(getSystemId(), getLineNumber())); trace.setContainer(procedure); body = trace; procedure.setName(getObjectName()); procedure.setBody(body); procedure.setSystemId(getSystemId()); procedure.setLineNumber(getLineNumber()); procedure.setExecutable(exec); procedure.setStackFrameMap(stackFrameMap); } catch (XPathException e) { compileError(e);
String streamableAtt = null; AttributeCollection atts = getAttributeList(); visibilityAtt = Whitespace.trim(atts.getValue(a)); } else { checkUnknownAttribute(atts.getNodeName(a)); reportAbsence("name"); setObjectName(new StructuredQName("", "", "attribute-set-error-name")); return; visibility = Visibility.PRIVATE; } else { visibility = interpretVisibilityValue(visibilityAtt, ""); streamable = processStreamableAtt(streamableAtt); setObjectName(makeQName(nameAtt)); } catch (XPathException err) { setObjectName(new StructuredQName("", "", "attribute-set-error-name")); err.setLocation(new AttributeLocation(this, StructuredQName.fromClarkName("name"))); throw err;
if (isActionCompleted(ACTION_COMPILE)) { return; getPrincipalStylesheetModule().getAttributeSets(name, attributeSetElements); ((XSLAttributeSet) attributeSetElement.getSourceElement()).checkCircularity(this); for (ComponentDeclaration attributeSetElement : attributeSetElements) { if (!((XSLAttributeSet) attributeSetElement.getSourceElement()).streamable) { compileError("Attribute set is declared streamable, " + "but references an attribute set that is not declared streamable", "XTSE0730"); AxisIterator iter = iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT); while ((node = (XSLAttribute) iter.next()) != null) { Expression inst = node.compile(compilation, decl); inst.setRetainedStaticContext(makeRetainedStaticContext()); inst = inst.simplify(); if (compilation.getCompilerInfo().isCompileWithTracing()) { inst = makeTraceInstruction(this, inst); setActionCompleted(ACTION_COMPILE);