本文整理汇总了Java中org.apache.xalan.transformer.TransformerImpl.getXPathContext方法的典型用法代码示例。如果您正苦于以下问题:Java TransformerImpl.getXPathContext方法的具体用法?Java TransformerImpl.getXPathContext怎么用?Java TransformerImpl.getXPathContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xalan.transformer.TransformerImpl
的用法示例。
在下文中一共展示了TransformerImpl.getXPathContext方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttribute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Return the value of the attribute interpreted as an Attribute
* Value Template (in other words, you can use curly expressions
* such as href="http://{website}".
*
* @param rawName Raw name of the attribute to get
* @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
* @param transformer non-null reference to the the current transform-time state.
*
* @return the value of the attribute
*
* @throws TransformerException
*/
public String getAttribute(
String rawName, org.w3c.dom.Node sourceNode, TransformerImpl transformer)
throws TransformerException
{
AVT avt = getLiteralResultAttribute(rawName);
if ((null != avt) && avt.getRawName().equals(rawName))
{
XPathContext xctxt = transformer.getXPathContext();
return avt.evaluate(xctxt,
xctxt.getDTMHandleFromNode(sourceNode),
this);
}
return null;
}
示例2: execute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Copy the template contents into the result tree.
* The content of the xsl:template element is the template
* that is instantiated when the template rule is applied.
*
* @param transformer non-null reference to the the current transform-time state.
*
* @throws TransformerException
*/
public void execute(
TransformerImpl transformer)
throws TransformerException
{
XPathContext xctxt = transformer.getXPathContext();
xctxt.pushRTFContext();
// %REVIEW% commenting out of the code below.
// if (null != sourceNode)
// {
transformer.executeChildTemplates(this, true);
// }
// else // if(null == sourceNode)
// {
// transformer.getMsgMgr().error(this,
// this, sourceNode,
// XSLTErrorResources.ER_NULL_SOURCENODE_HANDLEAPPLYTEMPLATES);
//
// //"sourceNode is null in handleApplyTemplatesInstruction!");
// }
xctxt.popRTFContext();
}
示例3: execute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Generate the EXSLT function return value, and assign it to the variable
* index slot assigned for it in ElemExsltFunction compose().
*
*/
public void execute(TransformerImpl transformer) throws TransformerException
{
XPathContext context = transformer.getXPathContext();
// Verify that result has not already been set by another result
// element. Recursion is allowed: intermediate results are cleared
// in the owner ElemExsltFunction execute().
if (transformer.currentFuncResultSeen()) {
throw new TransformerException("An EXSLT function cannot set more than one result!");
}
int sourceNode = context.getCurrentNode();
// Set the return value;
XObject var = getValue(transformer, sourceNode);
transformer.popCurrentFuncResult();
transformer.pushCurrentFuncResult(var);
}
示例4: execute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Conditionally execute a sub-template.
* The expression is evaluated and the resulting object is converted
* to a boolean as if by a call to the boolean function. If the result
* is true, then the content template is instantiated; otherwise, nothing
* is created.
*
* @param transformer non-null reference to the the current transform-time state.
*
* @throws TransformerException
*/
public void execute(TransformerImpl transformer) throws TransformerException
{
XPathContext xctxt = transformer.getXPathContext();
int sourceNode = xctxt.getCurrentNode();
if (m_test.bool(xctxt, sourceNode, this)) {
transformer.executeChildTemplates(this, true);
}
}
示例5: getLocale
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Get the locale we should be using.
*
* @param transformer non-null reference to the the current transform-time state.
* @param contextNode The node that "." expresses.
*
* @return The locale to use. May be specified by "lang" attribute,
* but if not, use default locale on the system.
*
* @throws TransformerException
*/
Locale getLocale(TransformerImpl transformer, int contextNode)
throws TransformerException
{
Locale locale = null;
if (null != m_lang_avt)
{
XPathContext xctxt = transformer.getXPathContext();
String langValue = m_lang_avt.evaluate(xctxt, contextNode, this);
if (null != langValue)
{
// Not really sure what to do about the country code, so I use the
// default from the system.
// TODO: fix xml:lang handling.
locale = new Locale(langValue.toUpperCase(), "");
//Locale.getDefault().getDisplayCountry());
if (null == locale)
{
transformer.getMsgMgr().warn(this, null, xctxt.getDTM(contextNode).getNode(contextNode),
XSLTErrorResources.WG_LOCALE_NOT_FOUND,
new Object[]{ langValue }); //"Warning: Could not find locale for xml:lang="+langValue);
locale = Locale.getDefault();
}
}
}
else
{
locale = Locale.getDefault();
}
return locale;
}
示例6: execute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Execute the xsl:choose transformation.
*
*
* @param transformer non-null reference to the the current transform-time state.
*
* @throws TransformerException
*/
public void execute(TransformerImpl transformer) throws TransformerException
{
boolean found = false;
for (ElemTemplateElement childElem = getFirstChildElem();
childElem != null; childElem = childElem.getNextSiblingElem())
{
int type = childElem.getXSLToken();
if (Constants.ELEMNAME_WHEN == type)
{
found = true;
ElemWhen when = (ElemWhen) childElem;
// must be xsl:when
XPathContext xctxt = transformer.getXPathContext();
int sourceNode = xctxt.getCurrentNode();
// System.err.println("\""+when.getTest().getPatternString()+"\"");
// if(when.getTest().getPatternString().equals("COLLECTION/icuser/ictimezone/LITERAL='GMT +13:00 Pacific/Tongatapu'"))
// System.err.println("Found COLLECTION/icuser/ictimezone/LITERAL");
if (when.getTest().bool(xctxt, sourceNode, when)) {
transformer.executeChildTemplates(when, true);
return;
}
}
else if (Constants.ELEMNAME_OTHERWISE == type)
{
found = true;
// xsl:otherwise
transformer.executeChildTemplates(childElem, true);
return;
}
}
if (!found)
transformer.getMsgMgr().error(
this, XSLTErrorResources.ER_CHOOSE_REQUIRES_WHEN);
}
示例7: execute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* The xsl:copy element provides an easy way of copying the current node.
* Executing this function creates a copy of the current node into the
* result tree.
* <p>The namespace nodes of the current node are automatically
* copied as well, but the attributes and children of the node are not
* automatically copied. The content of the xsl:copy element is a
* template for the attributes and children of the created node;
* the content is instantiated only for nodes of types that can have
* attributes or children (i.e. root nodes and element nodes).</p>
* <p>The root node is treated specially because the root node of the
* result tree is created implicitly. When the current node is the
* root node, xsl:copy will not create a root node, but will just use
* the content template.</p>
*
* @param transformer non-null reference to the the current transform-time state.
*
* @throws TransformerException
*/
public void execute(
TransformerImpl transformer)
throws TransformerException
{
XPathContext xctxt = transformer.getXPathContext();
try
{
int sourceNode = xctxt.getCurrentNode();
xctxt.pushCurrentNode(sourceNode);
DTM dtm = xctxt.getDTM(sourceNode);
short nodeType = dtm.getNodeType(sourceNode);
if ((DTM.DOCUMENT_NODE != nodeType) && (DTM.DOCUMENT_FRAGMENT_NODE != nodeType))
{
SerializationHandler rthandler = transformer.getSerializationHandler();
// TODO: Process the use-attribute-sets stuff
ClonerToResultTree.cloneToResultTree(sourceNode, nodeType, dtm,
rthandler, false);
if (DTM.ELEMENT_NODE == nodeType)
{
super.execute(transformer);
SerializerUtils.processNSDecls(rthandler, sourceNode, nodeType, dtm);
transformer.executeChildTemplates(this, true);
String ns = dtm.getNamespaceURI(sourceNode);
String localName = dtm.getLocalName(sourceNode);
transformer.getResultTreeHandler().endElement(ns, localName,
dtm.getNodeName(sourceNode));
}
}
else
{
super.execute(transformer);
transformer.executeChildTemplates(this, true);
}
}
catch(org.xml.sax.SAXException se)
{
throw new TransformerException(se);
}
finally
{
xctxt.popCurrentNode();
}
}
示例8: getCountString
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Given an XML source node, get the count according to the
* parameters set up by the xsl:number attributes.
* @param transformer non-null reference to the the current transform-time state.
* @param sourceNode The source node being counted.
*
* @return The count of nodes
*
* @throws TransformerException
*/
String getCountString(TransformerImpl transformer, int sourceNode)
throws TransformerException
{
long[] list = null;
XPathContext xctxt = transformer.getXPathContext();
CountersTable ctable = transformer.getCountersTable();
if (null != m_valueExpr)
{
XObject countObj = m_valueExpr.execute(xctxt, sourceNode, this);
//According to Errata E24
double d_count = java.lang.Math.floor(countObj.num()+ 0.5);
if (Double.isNaN(d_count)) return "NaN";
else if (d_count < 0 && Double.isInfinite(d_count)) return "-Infinity";
else if (Double.isInfinite(d_count)) return "Infinity";
else if (d_count == 0) return "0";
else{
long count = (long)d_count;
list = new long[1];
list[0] = count;
}
}
else
{
if (Constants.NUMBERLEVEL_ANY == m_level)
{
list = new long[1];
list[0] = ctable.countNode(xctxt, this, sourceNode);
}
else
{
NodeVector ancestors =
getMatchingAncestors(xctxt, sourceNode,
Constants.NUMBERLEVEL_SINGLE == m_level);
int lastIndex = ancestors.size() - 1;
if (lastIndex >= 0)
{
list = new long[lastIndex + 1];
for (int i = lastIndex; i >= 0; i--)
{
int target = ancestors.elementAt(i);
list[lastIndex - i] = ctable.countNode(xctxt, this, target);
}
}
}
}
return (null != list)
? formatNumberList(transformer, list, sourceNode) : "";
}
示例9: execute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Execute the string expression and copy the text to the
* result tree.
* The required select attribute is an expression; this expression
* is evaluated and the resulting object is converted to a string
* as if by a call to the string function. The string specifies
* the string-value of the created text node. If the string is
* empty, no text node will be created. The created text node will
* be merged with any adjacent text nodes.
* @see <a href="http://www.w3.org/TR/xslt#value-of">value-of in XSLT Specification</a>
*
* @param transformer non-null reference to the the current transform-time state.
*
* @throws TransformerException
*/
public void execute(TransformerImpl transformer) throws TransformerException
{
XPathContext xctxt = transformer.getXPathContext();
SerializationHandler rth = transformer.getResultTreeHandler();
try
{
// Optimize for "."
xctxt.pushNamespaceContext(this);
int current = xctxt.getCurrentNode();
xctxt.pushCurrentNodeAndExpression(current, current);
if (m_disableOutputEscaping)
rth.processingInstruction(
javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
try
{
Expression expr = m_selectExpression.getExpression();
expr.executeCharsToContentHandler(xctxt, rth);
}
finally
{
if (m_disableOutputEscaping)
rth.processingInstruction(
javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
xctxt.popNamespaceContext();
xctxt.popCurrentNodeAndExpression();
}
}
catch (SAXException se)
{
throw new TransformerException(se);
}
catch (RuntimeException re) {
TransformerException te = new TransformerException(re);
te.setLocator(this);
throw te;
}
}
示例10: execute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
/**
* Create a processing instruction in the result tree.
* The content of the xsl:processing-instruction element is a
* template for the string-value of the processing instruction node.
* @see <a href="http://www.w3.org/TR/xslt#section-Creating-Processing-Instructions">section-Creating-Processing-Instructions in XSLT Specification</a>
*
* @param transformer non-null reference to the the current transform-time state.
*
* @throws TransformerException
*/
public void execute(
TransformerImpl transformer)
throws TransformerException
{
XPathContext xctxt = transformer.getXPathContext();
int sourceNode = xctxt.getCurrentNode();
String piName = m_name_atv == null ? null : m_name_atv.evaluate(xctxt, sourceNode, this);
// Ignore processing instruction if name is null
if (piName == null) return;
if (piName.equalsIgnoreCase("xml"))
{
transformer.getMsgMgr().warn(
this, XSLTErrorResources.WG_PROCESSINGINSTRUCTION_NAME_CANT_BE_XML,
new Object[]{ Constants.ATTRNAME_NAME, piName });
return;
}
// Only check if an avt was used (ie. this wasn't checked at compose time.)
// Ignore processing instruction, if invalid
else if ((!m_name_atv.isSimple()) && (!XML11Char.isXML11ValidNCName(piName)))
{
transformer.getMsgMgr().warn(
this, XSLTErrorResources.WG_PROCESSINGINSTRUCTION_NOTVALID_NCNAME,
new Object[]{ Constants.ATTRNAME_NAME, piName });
return;
}
// Note the content model is:
// <!ENTITY % instructions "
// %char-instructions;
// | xsl:processing-instruction
// | xsl:comment
// | xsl:element
// | xsl:attribute
// ">
String data = transformer.transformToString(this);
try
{
transformer.getResultTreeHandler().processingInstruction(piName, data);
}
catch(org.xml.sax.SAXException se)
{
throw new TransformerException(se);
}
}
示例11: execute
import org.apache.xalan.transformer.TransformerImpl; //导入方法依赖的package包/类
public void execute(TransformerImpl transformer, XObject[] args)
throws TransformerException
{
XPathContext xctxt = transformer.getXPathContext();
VariableStack vars = xctxt.getVarStack();
// Increment the frame bottom of the variable stack by the
// frame size
int thisFrame = vars.getStackFrame();
int nextFrame = vars.link(m_frameSize);
if (m_inArgsSize < args.length) {
throw new TransformerException ("function called with too many args");
}
// Set parameters,
// have to clear the section of the stack frame that has params.
if (m_inArgsSize > 0) {
vars.clearLocalSlots(0, m_inArgsSize);
if (args.length > 0) {
vars.setStackFrame(thisFrame);
NodeList children = this.getChildNodes();
for (int i = 0; i < args.length; i ++) {
Node child = children.item(i);
if (children.item(i) instanceof ElemParam) {
ElemParam param = (ElemParam)children.item(i);
vars.setLocalVariable(param.getIndex(), args[i], nextFrame);
}
}
vars.setStackFrame(nextFrame);
}
}
// Removed ElemTemplate 'push' and 'pop' of RTFContext, in order to avoid losing the RTF context
// before a value can be returned. ElemExsltFunction operates in the scope of the template that called
// the function.
// xctxt.pushRTFContext();
vars.setStackFrame(nextFrame);
transformer.executeChildTemplates(this, true);
// Reset the stack frame after the function call
vars.unlink(thisFrame);
// Following ElemTemplate 'pop' removed -- see above.
// xctxt.popRTFContext();
}