/** * Return true if this extension element has a <xsl:fallback> child element. * * @return true if this extension element has a <xsl:fallback> child element. */ private boolean hasFallbackChildren() { for (ElemTemplateElement child = m_firstChild; child != null; child = child.m_nextSibling) { if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK) return true; } return false; }
/** * Return true if this extension element has a <xsl:fallback> child element. * * @return true if this extension element has a <xsl:fallback> child element. */ private boolean hasFallbackChildren() { for (ElemTemplateElement child = m_firstChild; child != null; child = child.m_nextSibling) { if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK) return true; } return false; }
/** * Return true if this extension element has a <xsl:fallback> child element. * * @return true if this extension element has a <xsl:fallback> child element. */ private boolean hasFallbackChildren() { for (ElemTemplateElement child = m_firstChild; child != null; child = child.m_nextSibling) { if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK) return true; } return false; }
/** * Return true if this extension element has a <xsl:fallback> child element. * * @return true if this extension element has a <xsl:fallback> child element. */ private boolean hasFallbackChildren() { for (ElemTemplateElement child = m_firstChild; child != null; child = child.m_nextSibling) { if (child.getXSLToken() == Constants.ELEMNAME_FALLBACK) return true; } return false; }
/** * Get the owning xsl:template element. * * @return The owning xsl:template element, this element if it is a xsl:template, or null if not found. */ public ElemTemplate getOwnerXSLTemplate() { ElemTemplateElement el = this; int type = el.getXSLToken(); while((null != el) && (type != Constants.ELEMNAME_TEMPLATE)) { el = el.getParentElem(); if(null != el) type = el.getXSLToken(); } return (ElemTemplate)el; }
/** * Get the owning xsl:template element. * * @return The owning xsl:template element, this element if it is a xsl:template, or null if not found. */ public ElemTemplate getOwnerXSLTemplate() { ElemTemplateElement el = this; int type = el.getXSLToken(); while((null != el) && (type != Constants.ELEMNAME_TEMPLATE)) { el = el.getParentElem(); if(null != el) type = el.getXSLToken(); } return (ElemTemplate)el; }
/** * Visit an XSLT top-level instruction. * * @param elem The xsl instruction element object. * @return true if the sub expressions should be traversed. */ public boolean visitTopLevelInstruction(ElemTemplateElement elem) { int type = elem.getXSLToken(); switch(type) { case Constants.ELEMNAME_TEMPLATE : return visitInstruction(elem); default: return true; } }
/** * Visit an XSLT top-level instruction. * * @param elem The xsl instruction element object. * @return true if the sub expressions should be traversed. */ public boolean visitTopLevelInstruction(ElemTemplateElement elem) { int type = elem.getXSLToken(); switch(type) { case Constants.ELEMNAME_TEMPLATE : return visitInstruction(elem); default: return true; } }
/** * Find the previous occurance of a xsl:variable. Stop * the search when a xsl:for-each, xsl:template, or xsl:stylesheet is * encountered. * * @param elem Should be non-null template element. * @return The first previous occurance of an xsl:variable or xsl:param, * or null if none is found. */ protected ElemVariable getPrevVariableElem(ElemTemplateElement elem) { // This could be somewhat optimized. since getPreviousSiblingElem is a // fairly expensive operation. while(null != (elem = getPrevElementWithinContext(elem))) { int type = elem.getXSLToken(); if((Constants.ELEMNAME_VARIABLE == type) || (Constants.ELEMNAME_PARAMVARIABLE == type)) { return (ElemVariable)elem; } } return null; }
/** * Get the call stack of xsl:template elements. * * @return A copy of stack that contains the xsl:template * (ElemTemplate) instructions, the earliest called in index * zero, and the latest called in index size()-1. */ public Vector getTemplateCallstack() { Vector elems = new Vector(); int nStackSize = m_currentTemplateElements.size(); for(int i = 0; i < nStackSize; i++) { ElemTemplateElement elem = (ElemTemplateElement) m_currentTemplateElements.elementAt(i); if(null != elem && (elem.getXSLToken() != Constants.ELEMNAME_TEMPLATE)) { elems.addElement(elem); } } return elems; }
/** * This method retrieves the xsl:template * that is in effect, which may be a matched template * or a named template. * * <p>Please note that the ElemTemplate returned may * be a default template, and thus may not have a template * defined in the stylesheet.</p> * * @return The current xsl:template, should not be null. */ public ElemTemplate getCurrentTemplate() { ElemTemplateElement elem = getCurrentElement(); while ((null != elem) && (elem.getXSLToken() != Constants.ELEMNAME_TEMPLATE)) { elem = elem.getParentElem(); } return (ElemTemplate) elem; }
/** * Add a child to the child list. * <!ELEMENT xsl:apply-templates (xsl:sort|xsl:with-param)*> * <!ATTLIST xsl:apply-templates * select %expr; "node()" * mode %qname; #IMPLIED * > * * @param newChild Child to add to child list * * @return Child just added to child list */ public ElemTemplateElement appendChild(ElemTemplateElement newChild) { int type = ((ElemTemplateElement) newChild).getXSLToken(); if (Constants.ELEMNAME_SORT == type) { setSortElem((ElemSort) newChild); return newChild; } else return super.appendChild(newChild); }
/** * Get the previous sibling or parent of the given template, stopping at * xsl:for-each, xsl:template, or xsl:stylesheet. * * @param elem Should be non-null template element. * @return previous sibling or parent, or null if previous is xsl:for-each, * xsl:template, or xsl:stylesheet. */ protected ElemTemplateElement getPrevElementWithinContext(ElemTemplateElement elem) { ElemTemplateElement prev = elem.getPreviousSiblingElem(); if(null == prev) prev = elem.getParentElem(); if(null != prev) { int type = prev.getXSLToken(); if((Constants.ELEMNAME_FOREACH == type) || (Constants.ELEMNAME_TEMPLATE == type) || (Constants.ELEMNAME_STYLESHEET == type)) { prev = null; } } return prev; }
/** * This method retrieves the xsl:template * that is in effect, which may be a matched template * or a named template. * * <p>Please note that the ElemTemplate returned may * be a default template, and thus may not have a template * defined in the stylesheet.</p> * * @return The current xsl:template, should not be null. */ public ElemTemplate getCurrentTemplate() { ElemTemplateElement elem = getCurrentElement(); while ((null != elem) && (elem.getXSLToken() != Constants.ELEMNAME_TEMPLATE)) { elem = elem.getParentElem(); } return (ElemTemplate) elem; }
/** * Add a child to the child list. * <!ELEMENT xsl:apply-templates (xsl:sort|xsl:with-param)*> * <!ATTLIST xsl:apply-templates * select %expr; "node()" * mode %qname; #IMPLIED * > * * @param newChild Child to add to this node's children list * * @return The child that was just added the children list * * @throws DOMException */ public ElemTemplateElement appendChild(ElemTemplateElement newChild) { int type = ((ElemTemplateElement) newChild).getXSLToken(); if (Constants.ELEMNAME_WITHPARAM == type) { setParamElem((ElemWithParam) newChild); } // You still have to append, because this element can // contain a for-each, and other elements. return super.appendChild(newChild); }
/** * This function is called after everything else has been * recomposed, and allows the template to set remaining * values that may be based on some other property that * depends on recomposition. */ public void compose(StylesheetRoot sroot) throws TransformerException { super.compose(sroot); m_qnameID = sroot.getComposeState().getQNameID(m_qname); int parentToken = m_parentNode.getXSLToken(); if (parentToken == Constants.ELEMNAME_TEMPLATE || parentToken == Constants.EXSLT_ELEMNAME_FUNCTION) ((ElemTemplate)m_parentNode).m_inArgsSize++; }
/** * This function is called after everything else has been * recomposed, and allows the template to set remaining * values that may be based on some other property that * depends on recomposition. */ public void compose(StylesheetRoot sroot) throws TransformerException { super.compose(sroot); m_qnameID = sroot.getComposeState().getQNameID(m_qname); int parentToken = m_parentNode.getXSLToken(); if (parentToken == Constants.ELEMNAME_TEMPLATE || parentToken == Constants.EXSLT_ELEMNAME_FUNCTION) ((ElemTemplate)m_parentNode).m_inArgsSize++; }
/** * Add a child to the child list. * * @param newChild Child to add to children list * * @return Child added to children list * * @throws DOMException */ public ElemTemplateElement appendChild(ElemTemplateElement newChild) { int type = ((ElemTemplateElement) newChild).getXSLToken(); switch (type) { case Constants.ELEMNAME_TEXTLITERALRESULT : break; default : error(XSLTErrorResources.ER_CANNOT_ADD, new Object[]{ newChild.getNodeName(), this.getNodeName() }); //"Can not add " +((ElemTemplateElement)newChild).m_elemName + //" to " + this.m_elemName); } return super.appendChild(newChild); } }
/** * This function is called after everything else has been * recomposed, and allows the template to set remaining * values that may be based on some other property that * depends on recomposition. */ public void compose(StylesheetRoot sroot) throws TransformerException { resolvePrefixTables(); ElemTemplateElement t = getFirstChildElem(); m_hasTextLitOnly = ((t != null) && (t.getXSLToken() == Constants.ELEMNAME_TEXTLITERALRESULT) && (t.getNextSiblingElem() == null)); StylesheetRoot.ComposeState cstate = sroot.getComposeState(); cstate.pushStackMark(); }
/** * This function is called after everything else has been * recomposed, and allows the template to set remaining * values that may be based on some other property that * depends on recomposition. */ public void compose(StylesheetRoot sroot) throws TransformerException { resolvePrefixTables(); ElemTemplateElement t = getFirstChildElem(); m_hasTextLitOnly = ((t != null) && (t.getXSLToken() == Constants.ELEMNAME_TEXTLITERALRESULT) && (t.getNextSiblingElem() == null)); StylesheetRoot.ComposeState cstate = sroot.getComposeState(); cstate.pushStackMark(); }