本文整理汇总了Java中org.apache.xml.dtm.DTM.getStringValue方法的典型用法代码示例。如果您正苦于以下问题:Java DTM.getStringValue方法的具体用法?Java DTM.getStringValue怎么用?Java DTM.getStringValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xml.dtm.DTM
的用法示例。
在下文中一共展示了DTM.getStringValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getArg0AsString
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
* Execute the first argument expression that is expected to return a
* string. If the argument is null, then get the string value from the
* current context node.
*
* @param xctxt Runtime XPath context.
*
* @return The string value of the first argument, or the string value of the
* current context node if the first argument is null.
*
* @throws javax.xml.transform.TransformerException if an error occurs while
* executing the argument expression.
*/
protected XMLString getArg0AsString(XPathContext xctxt)
throws javax.xml.transform.TransformerException
{
if(null == m_arg0)
{
int currentNode = xctxt.getCurrentNode();
if(DTM.NULL == currentNode)
return XString.EMPTYSTRING;
else
{
DTM dtm = xctxt.getDTM(currentNode);
return dtm.getStringValue(currentNode);
}
}
else
return m_arg0.execute(xctxt).xstr();
}
示例2: getArg0AsNumber
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
* Execute the first argument expression that is expected to return a
* number. If the argument is null, then get the number value from the
* current context node.
*
* @param xctxt Runtime XPath context.
*
* @return The number value of the first argument, or the number value of the
* current context node if the first argument is null.
*
* @throws javax.xml.transform.TransformerException if an error occurs while
* executing the argument expression.
*/
protected double getArg0AsNumber(XPathContext xctxt)
throws javax.xml.transform.TransformerException
{
if(null == m_arg0)
{
int currentNode = xctxt.getCurrentNode();
if(DTM.NULL == currentNode)
return 0;
else
{
DTM dtm = xctxt.getDTM(currentNode);
XMLString str = dtm.getStringValue(currentNode);
return str.toDouble();
}
}
else
return m_arg0.execute(xctxt).num();
}
示例3: execute
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
* Execute the function. The function must return
* a valid object.
* @param xctxt The current execution context.
* @return A valid XObject.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{
DTMIterator nodes = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
double sum = 0.0;
int pos;
while (DTM.NULL != (pos = nodes.nextNode()))
{
DTM dtm = nodes.getDTM(pos);
XMLString s = dtm.getStringValue(pos);
if (null != s)
sum += s.toDouble();
}
nodes.detach();
return new XNumber(sum);
}
示例4: toNumber
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
* Get the value of a node as a number.
* @param n Node to be converted to a number. May be null.
* @return value of n as a number.
*/
public double toNumber(org.w3c.dom.Node n)
{
// %REVIEW% You can't get much uglier than this...
int nodeHandle = getDTMHandleFromNode(n);
DTM dtm = getDTM(nodeHandle);
XString xobj = (XString)dtm.getStringValue(nodeHandle);
return xobj.num();
}
示例5: toString
import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
* Get the value of a node as a string.
* @param n Node to be converted to a string. May be null.
* @return value of n as a string, or an empty string if n is null.
*/
public String toString(org.w3c.dom.Node n)
{
// %REVIEW% You can't get much uglier than this...
int nodeHandle = getDTMHandleFromNode(n);
DTM dtm = getDTM(nodeHandle);
XMLString strVal = dtm.getStringValue(nodeHandle);
return strVal.toString();
}