net.sf.saxon.style.XSLResultDocument Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of saxon-he Show documentation
Show all versions of saxon-he Show documentation
An OSGi bundle for Saxon-HE
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2013 Saxonica Limited.
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package net.sf.saxon.style;
import net.sf.saxon.expr.ErrorExpression;
import net.sf.saxon.expr.Expression;
import net.sf.saxon.expr.Literal;
import net.sf.saxon.expr.StringLiteral;
import net.sf.saxon.expr.instruct.Executable;
import net.sf.saxon.expr.instruct.ResultDocument;
import net.sf.saxon.lib.FeatureKeys;
import net.sf.saxon.z.IntHashMap;
import net.sf.saxon.z.IntHashSet;
import net.sf.saxon.z.IntIterator;
import net.sf.saxon.lib.NamespaceConstant;
import net.sf.saxon.lib.Validation;
import net.sf.saxon.om.*;
import net.sf.saxon.trans.SaxonErrorCode;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.tree.iter.AxisIterator;
import net.sf.saxon.type.ItemType;
import net.sf.saxon.type.SchemaType;
import net.sf.saxon.value.EmptySequence;
import net.sf.saxon.value.Whitespace;
import java.util.HashSet;
import java.util.Properties;
/**
* An xsl:result-document element in the stylesheet.
* The xsl:result-document element takes an attribute href="filename". The filename will
* often contain parameters, e.g. {position()} to ensure that a different file is produced
* for each element instance.
* There is a further attribute "name" which determines the format of the
* output file, it identifies the name of an xsl:output element containing the output
* format details.
*/
public class XSLResultDocument extends StyleElement {
private static final HashSet fans = new HashSet(25); // formatting attribute names
static {
fans.add(StandardNames.METHOD);
fans.add(StandardNames.OUTPUT_VERSION);
fans.add(StandardNames.HTML_VERSION);
fans.add(StandardNames.BYTE_ORDER_MARK);
fans.add(StandardNames.INDENT);
fans.add(StandardNames.ENCODING);
fans.add(StandardNames.MEDIA_TYPE);
fans.add(StandardNames.DOCTYPE_SYSTEM);
fans.add(StandardNames.DOCTYPE_PUBLIC);
fans.add(StandardNames.OMIT_XML_DECLARATION);
fans.add(StandardNames.STANDALONE);
fans.add(StandardNames.CDATA_SECTION_ELEMENTS);
fans.add(StandardNames.INCLUDE_CONTENT_TYPE);
fans.add(StandardNames.ESCAPE_URI_ATTRIBUTES);
fans.add(StandardNames.UNDECLARE_PREFIXES);
fans.add(StandardNames.NORMALIZATION_FORM);
fans.add(StandardNames.SAXON_NEXT_IN_CHAIN);
fans.add(StandardNames.SAXON_CHARACTER_REPRESENTATION);
fans.add(StandardNames.SAXON_INDENT_SPACES);
fans.add(StandardNames.SAXON_REQUIRE_WELL_FORMED);
fans.add(StandardNames.SAXON_SUPPRESS_INDENTATION);
fans.add(StandardNames.SAXON_ATTRIBUTE_ORDER);
}
private Expression href;
private StructuredQName formatQName; // used when format is a literal string
private Expression formatExpression; // used when format is an AVT
private int validationAction = Validation.STRIP;
private SchemaType schemaType = null;
private IntHashMap serializationAttributes = new IntHashMap(10);
private boolean async = true;
/**
* Determine whether this node is an instruction.
* @return true - it is an instruction
*/
public boolean isInstruction() {
return true;
}
/**
* Determine whether this type of element is allowed to contain a template-body
* @return true: yes, it may contain a template-body
*/
public boolean mayContainSequenceConstructor() {
return true;
}
/**
* Determine the type of item returned by this instruction (only relevant if
* it is an instruction). Default implementation returns Type.ITEM, indicating
* that we don't know, it might be anything. Returns null in the case of an element
* such as xsl:sort or xsl:variable that can appear in a sequence constructor but
* contributes nothing to the result sequence.
* @return the item type returned
*/
protected ItemType getReturnedItemType() {
return null;
}
public void prepareAttributes() throws XPathException {
AttributeCollection atts = getAttributeList();
String formatAttribute = null;
String hrefAttribute = null;
String validationAtt = null;
String typeAtt = null;
String useCharacterMapsAtt = null;
for (int a=0; a