net.sf.saxon.style.XSLAttributeSet Maven / Gradle / Ivy
package net.sf.saxon.style;
import net.sf.saxon.expr.Expression;
import net.sf.saxon.expr.ExpressionVisitor;
import net.sf.saxon.expr.Literal;
import net.sf.saxon.instruct.*;
import net.sf.saxon.om.*;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.type.AnyItemType;
import net.sf.saxon.value.Whitespace;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* An xsl:attribute-set element in the stylesheet.
*/
public class XSLAttributeSet extends StyleElement implements StylesheetProcedure {
private String nameAtt;
// the name of the attribute set as written
private String useAtt;
// the value of the use-attribute-sets attribute, as supplied
private SlotManager stackFrameMap;
// needed if variables are used
private List attributeSetElements = null;
// list of XSLAttributeSet objects referenced by this one
private AttributeSet[] useAttributeSets = null;
// compiled instructions for the attribute sets used by this one
private AttributeSet procedure = new AttributeSet();
// the compiled form of this attribute set
private int referenceCount = 0;
// the number of references to this attribute set
private boolean validated = false;
/**
* Get the name of this attribute set
* @return the name of the attribute set, as a QName
*/
public StructuredQName getAttributeSetName() {
return getObjectName();
}
/**
* Get the compiled code produced for this XSLT element
* @return the compiled AttributeSet
*/
public AttributeSet getInstruction() {
return procedure;
}
/**
* Increment the number of references found to this attribute set
*/
public void incrementReferenceCount() {
referenceCount++;
}
public void prepareAttributes() throws XPathException {
useAtt = null;
AttributeCollection atts = getAttributeList();
for (int a=0; a 0 ) {
Expression body = compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);
if (body == null) {
body = Literal.makeEmptySequence();
}
try {
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.setUseAttributeSets(useAttributeSets);
procedure.setName(getObjectName());
procedure.setBody(body);
procedure.setSystemId(getSystemId());
procedure.setLineNumber(getLineNumber());
procedure.setExecutable(exec);
Expression exp2 = body.optimize(visitor, AnyItemType.getInstance());
if (body != exp2) {
procedure.setBody(exp2);
body = exp2;
}
super.allocateSlots(body);
procedure.setStackFrameMap(stackFrameMap);
} catch (XPathException e) {
compileError(e);
}
}
return null;
}
/**
* Get the type of construct. This will be a constant in
* class {@link net.sf.saxon.trace.Location}. This method is part of
* the {@link net.sf.saxon.trace.InstructionInfo} interface
*/
public int getConstructType() {
return StandardNames.XSL_ATTRIBUTE_SET;
}
}
//
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
// you may not use this file except in compliance with the License. You may obtain a copy of the
// License at http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
// See the License for the specific language governing rights and limitations under the License.
//
// The Original Code is: all this file.
//
// The Initial Developer of the Original Code is Michael H. Kay.
//
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
//
// Contributor(s): none.
//
© 2015 - 2025 Weber Informatics LLC | Privacy Policy