use of org.apache.xml.dtm.DTM in project robovm by robovm.
the class FuncId method getNodesByID.
/**
* Fill in a list with nodes that match a space delimited list if ID
* ID references.
*
* @param xctxt The runtime XPath context.
* @param docContext The document where the nodes are being looked for.
* @param refval A space delimited list of ID references.
* @param usedrefs List of references for which nodes were found.
* @param nodeSet Node set where the nodes will be added to.
* @param mayBeMore true if there is another set of nodes to be looked for.
*
* @return The usedrefs value.
*/
private StringVector getNodesByID(XPathContext xctxt, int docContext, String refval, StringVector usedrefs, NodeSetDTM nodeSet, boolean mayBeMore) {
if (null != refval) {
String ref = null;
// DOMHelper dh = xctxt.getDOMHelper();
StringTokenizer tokenizer = new StringTokenizer(refval);
boolean hasMore = tokenizer.hasMoreTokens();
DTM dtm = xctxt.getDTM(docContext);
while (hasMore) {
ref = tokenizer.nextToken();
hasMore = tokenizer.hasMoreTokens();
if ((null != usedrefs) && usedrefs.contains(ref)) {
ref = null;
continue;
}
int node = dtm.getElementById(ref);
if (DTM.NULL != node)
nodeSet.addNodeInDocOrder(node, xctxt);
if ((null != ref) && (hasMore || mayBeMore)) {
if (null == usedrefs)
usedrefs = new StringVector();
usedrefs.addElement(ref);
}
}
}
return usedrefs;
}
use of org.apache.xml.dtm.DTM in project robovm by robovm.
the class FuncLang method execute.
/**
* 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 {
String lang = m_arg0.execute(xctxt).str();
int parent = xctxt.getCurrentNode();
boolean isLang = false;
DTM dtm = xctxt.getDTM(parent);
while (DTM.NULL != parent) {
if (DTM.ELEMENT_NODE == dtm.getNodeType(parent)) {
int langAttr = dtm.getAttributeNode(parent, "http://www.w3.org/XML/1998/namespace", "lang");
if (DTM.NULL != langAttr) {
String langVal = dtm.getNodeValue(langAttr);
// %OPT%
if (langVal.toLowerCase().startsWith(lang.toLowerCase())) {
int valLen = lang.length();
if ((langVal.length() == valLen) || (langVal.charAt(valLen) == '-')) {
isLang = true;
}
}
break;
}
}
parent = dtm.getParent(parent);
}
return isLang ? XBoolean.S_TRUE : XBoolean.S_FALSE;
}
use of org.apache.xml.dtm.DTM in project robovm by robovm.
the class FuncLocalPart method execute.
/**
* 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 {
int context = getArg0AsNode(xctxt);
if (DTM.NULL == context)
return XString.EMPTYSTRING;
DTM dtm = xctxt.getDTM(context);
String s = (context != DTM.NULL) ? dtm.getLocalName(context) : "";
if (s.startsWith("#") || s.equals("xmlns"))
return XString.EMPTYSTRING;
return new XString(s);
}
use of org.apache.xml.dtm.DTM in project robovm by robovm.
the class FuncNamespace method execute.
/**
* 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 {
int context = getArg0AsNode(xctxt);
String s;
if (context != DTM.NULL) {
DTM dtm = xctxt.getDTM(context);
int t = dtm.getNodeType(context);
if (t == DTM.ELEMENT_NODE) {
s = dtm.getNamespaceURI(context);
} else if (t == DTM.ATTRIBUTE_NODE) {
// This function always returns an empty string for namespace nodes.
// We check for those here. Fix inspired by Davanum Srinivas.
s = dtm.getNodeName(context);
if (s.startsWith("xmlns:") || s.equals("xmlns"))
return XString.EMPTYSTRING;
s = dtm.getNamespaceURI(context);
} else
return XString.EMPTYSTRING;
} else
return XString.EMPTYSTRING;
return ((null == s) ? XString.EMPTYSTRING : new XString(s));
}
use of org.apache.xml.dtm.DTM in project robovm by robovm.
the class FuncNormalizeSpace method executeCharsToContentHandler.
/**
* Execute an expression in the XPath runtime context, and return the
* result of the expression.
*
*
* @param xctxt The XPath runtime context.
*
* @return The result of the expression in the form of a <code>XObject</code>.
*
* @throws javax.xml.transform.TransformerException if a runtime exception
* occurs.
*/
public void executeCharsToContentHandler(XPathContext xctxt, ContentHandler handler) throws javax.xml.transform.TransformerException, org.xml.sax.SAXException {
if (Arg0IsNodesetExpr()) {
int node = getArg0AsNode(xctxt);
if (DTM.NULL != node) {
DTM dtm = xctxt.getDTM(node);
dtm.dispatchCharactersEvents(node, handler, true);
}
} else {
XObject obj = execute(xctxt);
obj.dispatchCharactersEvents(handler);
}
}
Aggregations