stylesheetroot.java
来自「java jdk 1.4的源码」· Java 代码 · 共 1,336 行 · 第 1/3 页
JAVA
1,336 行
* TODO: JKESS PROPOSES SPECIAL-CASE FOR NO IMPORT LIST, TO MATCH DESCRIPTION. */ public int getGlobalImportCount() { return (m_globalImportList!=null) ? m_globalImportList.length : 1; } /** * Given a stylesheet, return the number of the stylesheet * in the global import list. * @param sheet The stylesheet which will be located in the * global import list. * @return The index into the global import list of the given stylesheet, * or -1 if it is not found (which should never happen). */ public int getImportNumber(StylesheetComposed sheet) { if (this == sheet) return 0; int n = getGlobalImportCount(); for (int i = 0; i < n; i++) { if (sheet == getGlobalImport(i)) return i; } return -1; } /** * This will be set up with the default values, and then the values * will be set as stylesheets are encountered. * @serial */ private OutputProperties m_outputProperties; /** * Recompose the output format object from the included elements. * * @param oprops non-null reference to xsl:output properties representation. */ void recomposeOutput(OutputProperties oprops) throws TransformerException { m_outputProperties.copyFrom(oprops); } /** * Get the combined "xsl:output" property with the properties * combined from the included stylesheets. If a xsl:output * is not declared in this stylesheet or an included stylesheet, * look in the imports. * Please note that this returns a reference to the OutputProperties * object, not a cloned object, like getOutputProperties does. * @see <a href="http://www.w3.org/TR/xslt#output">output in XSLT Specification</a> * * @return non-null reference to composed output properties object. */ public OutputProperties getOutputComposed() { // System.out.println("getOutputComposed.getIndent: "+m_outputProperties.getIndent()); // System.out.println("getOutputComposed.getIndenting: "+m_outputProperties.getIndenting()); return m_outputProperties; } /** Flag indicating whether an output method has been set by the user. * @serial */ private boolean m_outputMethodSet = false; /** * <meta name="usage" content="internal"/> * Find out if an output method has been set by the user. * * @return Value indicating whether an output method has been set by the user */ public boolean isOutputMethodSet() { return m_outputMethodSet; } /** * Composed set of all included and imported attribute set properties. * Each entry is a vector of ElemAttributeSet objects. * @serial */ private Hashtable m_attrSets; /** * Recompose the attribute-set declarations. * * @param attrSet An attribute-set to add to the hashtable of attribute sets. */ void recomposeAttributeSets(ElemAttributeSet attrSet) { Vector attrSetList = (Vector) m_attrSets.get(attrSet.getName()); if (null == attrSetList) { attrSetList = new Vector(); m_attrSets.put(attrSet.getName(), attrSetList); } attrSetList.addElement(attrSet); } /** * Get a list "xsl:attribute-set" properties that match the qname. * @see <a href="http://www.w3.org/TR/xslt#attribute-sets">attribute-sets in XSLT Specification</a> * * @param name Qualified name of attribute set properties to get * * @return A vector of attribute sets matching the given name * * @throws ArrayIndexOutOfBoundsException */ public Vector getAttributeSetComposed(QName name) throws ArrayIndexOutOfBoundsException { return (Vector) m_attrSets.get(name); } /** * Table of DecimalFormatSymbols, keyed by QName. * @serial */ private Hashtable m_decimalFormatSymbols; /** * Recompose the decimal-format declarations. * * @param dfp A DecimalFormatProperties to add to the hashtable of decimal formats. */ void recomposeDecimalFormats(DecimalFormatProperties dfp) { DecimalFormatSymbols oldDfs = (DecimalFormatSymbols) m_decimalFormatSymbols.get(dfp.getName()); if (null == oldDfs) { m_decimalFormatSymbols.put(dfp.getName(), dfp.getDecimalFormatSymbols()); } else if (!dfp.getDecimalFormatSymbols().equals(oldDfs)) { String themsg; if (dfp.getName().equals(new QName(""))) { // "Only one default xsl:decimal-format declaration is allowed." themsg = XSLMessages.createWarning( XSLTErrorResources.WG_ONE_DEFAULT_XSLDECIMALFORMAT_ALLOWED, new Object[0]); } else { // "xsl:decimal-format names must be unique. Name {0} has been duplicated." themsg = XSLMessages.createWarning( XSLTErrorResources.WG_XSLDECIMALFORMAT_NAMES_MUST_BE_UNIQUE, new Object[] {dfp.getName()}); } error(themsg); // Should we throw TransformerException instead? } } /** * Given a valid element decimal-format name, return the * decimalFormatSymbols with that name. * <p>It is an error to declare either the default decimal-format or * a decimal-format with a given name more than once (even with * different import precedence), unless it is declared every * time with the same value for all attributes (taking into * account any default values).</p> * <p>Which means, as far as I can tell, the decimal-format * properties are not additive.</p> * * @param name Qualified name of the decimal format to find * @return DecimalFormatSymbols object matching the given name or * null if name is not found. */ public DecimalFormatSymbols getDecimalFormatComposed(QName name) { return (DecimalFormatSymbols) m_decimalFormatSymbols.get(name); } /** * A list of all key declarations visible from this stylesheet and all * lesser stylesheets. * @serial */ private Vector m_keyDecls; /** * Recompose the key declarations. * * @param keyDecl A KeyDeclaration to be added to the vector of key declarations. */ void recomposeKeys(KeyDeclaration keyDecl) { m_keyDecls.addElement(keyDecl); } /** * Get the composed "xsl:key" properties. * @see <a href="http://www.w3.org/TR/xslt#key">key in XSLT Specification</a> * * @return A vector of the composed "xsl:key" properties. */ public Vector getKeysComposed() { return m_keyDecls; } /** * Composed set of all namespace aliases. * @serial */ private Hashtable m_namespaceAliasComposed; /** * Recompose the namespace-alias declarations. * * @param nsAlias A NamespaceAlias object to add to the hashtable of namespace aliases. */ void recomposeNamespaceAliases(NamespaceAlias nsAlias) { m_namespaceAliasComposed.put(nsAlias.getStylesheetNamespace(), nsAlias); } /** * Get the "xsl:namespace-alias" property. * Return the NamespaceAlias for a given namespace uri. * @see <a href="http://www.w3.org/TR/xslt#literal-result-element">literal-result-element in XSLT Specification</a> * * @param uri non-null reference to namespace that is to be aliased. * * @return NamespaceAlias that matches uri, or null if no match. */ public NamespaceAlias getNamespaceAliasComposed(String uri) { return (NamespaceAlias) ((null == m_namespaceAliasComposed) ? null : m_namespaceAliasComposed.get(uri)); } /** * The "xsl:template" properties. * @serial */ private TemplateList m_templateList; /** * Recompose the template declarations. * * @param template An ElemTemplate object to add to the template list. */ void recomposeTemplates(ElemTemplate template) { m_templateList.setTemplate(template); } /** * Accessor method to retrieve the <code>TemplateList</code> associated with * this StylesheetRoot. * * @return The composed <code>TemplateList</code>. */ public final TemplateList getTemplateListComposed() { return m_templateList; } /** * Mutator method to set the <code>TemplateList</code> associated with this * StylesheetRoot. This method should only be used by the compiler. Normally, * the template list is built during the recompose process and should not be * altered by the user. * @param templateList The new <code>TemplateList</code> for this StylesheetRoot. */ public final void setTemplateListComposed(TemplateList templateList) { m_templateList = templateList; } /** * Get an "xsl:template" property by node match. This looks in the imports as * well as this stylesheet. * @see <a href="http://www.w3.org/TR/xslt#section-Defining-Template-Rules">section-Defining-Template-Rules in XSLT Specification</a> * * @param xctxt non-null reference to XPath runtime execution context. * @param targetNode non-null reference of node that the template must match. * @param mode qualified name of the node, or null. * @param quietConflictWarnings true if conflict warnings should not be reported. * * @return reference to ElemTemplate that is the best match for targetNode, or * null if no match could be made. * * @throws TransformerException */ public ElemTemplate getTemplateComposed(XPathContext xctxt, int targetNode, QName mode, boolean quietConflictWarnings, DTM dtm) throws TransformerException { return m_templateList.getTemplate(xctxt, targetNode, mode, quietConflictWarnings, dtm); } /** * Get an "xsl:template" property by node match. This looks in the imports as * well as this stylesheet. * @see <a href="http://www.w3.org/TR/xslt#section-Defining-Template-Rules">section-Defining-Template-Rules in XSLT Specification</a> * * @param xctxt non-null reference to XPath runtime execution context. * @param targetNode non-null reference of node that the template must match. * @param mode qualified name of the node, or null. * @param maxImportLevel The maximum importCountComposed that we should consider or -1 * if we should consider all import levels. This is used by apply-imports to * access templates that have been overridden. * @param endImportLevel The count of composed imports * @param quietConflictWarnings true if conflict warnings should not be reported. * * @return reference to ElemTemplate that is the best match for targetNode, or * null if no match could be made. * * @throws TransformerException */ public ElemTemplate getTemplateComposed(XPathContext xctxt, int targetNode, QName mode, int maxImportLevel, int endImportLevel, boolean quietConflictWarnings, DTM dtm) throws TransformerException { return m_templateList.getTemplate(xctxt, targetNode, mode, maxImportLevel, endImportLevel, quietConflictWarnings, dtm); } /** * Get an "xsl:template" property. This looks in the imports as * well as this stylesheet. * @see <a href="http://www.w3.org/TR/xslt#section-Defining-Template-Rules">section-Defining-Template-Rules in XSLT Specification</a> * * @param qname non-null reference to qualified name of template. * * @return reference to named template, or null if not found. */ public ElemTemplate getTemplateComposed(QName qname) { return m_templateList.getTemplate(qname); } /** * Composed set of all variables and params. * @serial */ private Vector m_variables; /** * Recompose the top level variable and parameter declarations. * * @param elemVar A top level variable or parameter to be added to the Vector. */ void recomposeVariables(ElemVariable elemVar) { // Don't overide higher priority variable if (getVariableOrParamComposed(elemVar.getName()) == null) { elemVar.setIsTopLevel(true); // Mark as a top-level variable or param elemVar.setIndex(m_variables.size()); m_variables.addElement(elemVar); } } /** * Get an "xsl:variable" property. * @see <a href="http://www.w3.org/TR/xslt#top-level-variables">top-level-variables in XSLT Specification</a> * * @param qname Qualified name of variable or param * * @return The ElemVariable with the given qualified name */ public ElemVariable getVariableOrParamComposed(QName qname) { if (null != m_variables) { int n = m_variables.size(); for (int i = 0; i < n; i++) { ElemVariable var = (ElemVariable)m_variables.elementAt(i); if(var.getName().equals(qname)) return var; } } return null; } /** * Get all global "xsl:variable" properties in scope for this stylesheet. * @see <a href="http://www.w3.org/TR/xslt#top-level-variables">top-level-variables in XSLT Specification</a> * * @return Vector of all variables and params in scope */ public Vector getVariablesAndParamsComposed() { return m_variables; } /** * A list of properties that specify how to do space * stripping. This uses the same exact mechanism as Templates. * @serial */ private TemplateList m_whiteSpaceInfoList; /** * Recompose the strip-space and preserve-space declarations. * * @param wsi A WhiteSpaceInfo element to add to the list of WhiteSpaceInfo elements. */ void recomposeWhiteSpaceInfo(WhiteSpaceInfo wsi) { if (null == m_whiteSpaceInfoList) m_whiteSpaceInfoList = new TemplateList(); m_whiteSpaceInfoList.setTemplate(wsi); } /** * Check to see if the caller should bother with check for * whitespace nodes. *
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?