本文整理汇总了Java中org.apache.xalan.templates.ElemTemplateElement.getParentElem方法的典型用法代码示例。如果您正苦于以下问题:Java ElemTemplateElement.getParentElem方法的具体用法?Java ElemTemplateElement.getParentElem怎么用?Java ElemTemplateElement.getParentElem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xalan.templates.ElemTemplateElement
的用法示例。
在下文中一共展示了ElemTemplateElement.getParentElem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ancestorIsOk
import org.apache.xalan.templates.ElemTemplateElement; //导入方法依赖的package包/类
/**
* Verify that a literal result belongs to a result element, a variable,
* or a parameter.
*/
boolean ancestorIsOk(ElemTemplateElement child)
{
while (child.getParentElem() != null && !(child.getParentElem() instanceof ElemExsltFunction))
{
ElemTemplateElement parent = child.getParentElem();
if (parent instanceof ElemExsltFuncResult
|| parent instanceof ElemVariable
|| parent instanceof ElemParam
|| parent instanceof ElemMessage)
return true;
child = parent;
}
return false;
}
示例2: getElemVersion
import org.apache.xalan.templates.ElemTemplateElement; //导入方法依赖的package包/类
private double getElemVersion()
{
ElemTemplateElement elem = getElemTemplateElement();
double version = -1;
while ((version == -1 || version == Constants.XSLTVERSUPPORTED) && elem != null)
{
try{
version = Double.valueOf(elem.getXmlVersion()).doubleValue();
}
catch (Exception ex)
{
version = -1;
}
elem = elem.getParentElem();
}
return (version == -1)? Constants.XSLTVERSUPPORTED : version;
}
示例3: startElement
import org.apache.xalan.templates.ElemTemplateElement; //导入方法依赖的package包/类
/**
* Verify that the func:result element does not appear within a variable,
* parameter, or another func:result, and that it belongs to a func:function
* element.
*/
public void startElement(
StylesheetHandler handler, String uri, String localName, String rawName, Attributes attributes)
throws SAXException
{
String msg = "";
super.startElement(handler, uri, localName, rawName, attributes);
ElemTemplateElement ancestor = handler.getElemTemplateElement().getParentElem();
while (ancestor != null && !(ancestor instanceof ElemExsltFunction))
{
if (ancestor instanceof ElemVariable
|| ancestor instanceof ElemParam
|| ancestor instanceof ElemExsltFuncResult)
{
msg = "func:result cannot appear within a variable, parameter, or another func:result.";
handler.error(msg, new SAXException(msg));
}
ancestor = ancestor.getParentElem();
}
if (ancestor == null)
{
msg = "func:result must appear in a func:function element";
handler.error(msg, new SAXException(msg));
}
}
示例4: getCurrentTemplate
import org.apache.xalan.templates.ElemTemplateElement; //导入方法依赖的package包/类
/**
* 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;
}
示例5: validate
import org.apache.xalan.templates.ElemTemplateElement; //导入方法依赖的package包/类
/**
* Non-recursive traversal of FunctionElement tree based on TreeWalker to verify that
* there are no literal result elements except within a func:result element and that
* the func:result element does not contain any following siblings except xsl:fallback.
*/
public void validate(ElemTemplateElement elem, StylesheetHandler handler)
throws SAXException
{
String msg = "";
while (elem != null)
{
//System.out.println("elem " + elem);
if (elem instanceof ElemExsltFuncResult
&& elem.getNextSiblingElem() != null
&& !(elem.getNextSiblingElem() instanceof ElemFallback))
{
msg = "func:result has an illegal following sibling (only xsl:fallback allowed)";
handler.error(msg, new SAXException(msg));
}
if((elem instanceof ElemApplyImport
|| elem instanceof ElemApplyTemplates
|| elem instanceof ElemAttribute
|| elem instanceof ElemCallTemplate
|| elem instanceof ElemComment
|| elem instanceof ElemCopy
|| elem instanceof ElemCopyOf
|| elem instanceof ElemElement
|| elem instanceof ElemLiteralResult
|| elem instanceof ElemNumber
|| elem instanceof ElemPI
|| elem instanceof ElemText
|| elem instanceof ElemTextLiteral
|| elem instanceof ElemValueOf)
&& !(ancestorIsOk(elem)))
{
msg ="misplaced literal result in a func:function container.";
handler.error(msg, new SAXException(msg));
}
ElemTemplateElement nextElem = elem.getFirstChildElem();
while (nextElem == null)
{
nextElem = elem.getNextSiblingElem();
if (nextElem == null)
elem = elem.getParentElem();
if (elem == null || elem instanceof ElemExsltFunction)
return; // ok
}
elem = nextElem;
}
}