Constructor and Description |
---|
XPathImpl(Node document)
Constructor that receives the document in context
|
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
getMap(String xpath)
Selects a node with the given XPath and converts it to a
Map , by using IXPath.toMap(Node) . |
Map<String,Object> |
getMap(String xpath,
Node context)
Selects a node with the given XPath and converts it to a
Map , by using IXPath.toMap(Node) . |
List<Map<String,Object>> |
getMaps(String xpath)
Selects nodes with the given XPath and converts them to a
List of Map , by using
IXPath.toMap(Node) in each of these nodes. |
List<Map<String,Object>> |
getMaps(String xpath,
Node context)
Selects nodes with the given XPath and converts them to a
List of Map , by using
IXPath.toMap(Node) in each of these nodes. |
List<Node> |
selectNodes(String xpath)
Returns a
node list with the selected nodes by the given XPath using the document in context. |
List<Node> |
selectNodes(String xpath,
Node context)
Returns a
node list with the selected nodes by the given XPath in the given context . |
Node |
selectSingleNode(String xpath)
Returns a single node selected by the given XPath expression using the document in context.
|
Node |
selectSingleNode(String xpath,
Node context)
Returns a single node selected by the given XPath expression in the given
context . |
Map<String,Object> |
toMap(Node node)
Returns a Map object based on the given node.
|
String |
valueOf(String xpath,
Node context)
Returns the string representation of the evaluated XPath in the given context.
|
public XPathImpl(Node document)
document
- public String valueOf(String xpath, Node context)
IXPath
public List<Node> selectNodes(String xpath, Node context)
IXPath
node list
with the selected nodes by the given XPath in the given context
.selectNodes
in interface IXPath
xpath
- the XPath expression.context
- the context node.node list
with the selected nodes by the given XPath.public List<Node> selectNodes(String xpath)
IXPath
node list
with the selected nodes by the given XPath using the document in context.selectNodes
in interface IXPath
xpath
- the XPath expression.node list
with the selected nodes by the given XPath.public Node selectSingleNode(String xpath, Node context)
IXPath
context
. If more than one node is selected, the first one is
returned. If there's no such node, null
is returned.selectSingleNode
in interface IXPath
xpath
- the XPath expression.context
- the context node.public Node selectSingleNode(String xpath)
IXPath
null
is returned.selectSingleNode
in interface IXPath
xpath
- the XPath expression.public Map<String,Object> toMap(Node node)
IXPath
The conversion rules are as follows:
var myValue = myMap.myNode;
, the variable myValue
will have the value Some textother textanother text
.
If the element node is a simple element node with attributes, then its value will become available under the $
object, inside the node object.
For example, the given XML node:
var myValue = myMap.myNode.$;
, the variable myValue
will have the value Some textother textanother text
.
If the node is a complex node then its text (inner CDATA sections
and text nodes
) will not
be accessible. This kind of node is simply a container for inner nodes.
For example, the given XML node:
myNode
will not be accessible at all and the text of node myOtherNode
will be accessible using myMap.myNode.myOtherNode
.
Another aspect of element nodes is when they are automatically wrapped in arrays. It happens in the following situations:
lumIsArray
with the value true
.lumIsArray
attribute or the value of lumIsArray
attribute is not false
.row
and its parent node name is data
and the child element node either doesn't have the
lumIsArray
attribute or the value of lumIsArray
attribute is not false
.myAttribute
becomes available using the name $myAttribute
.
For example, the given XML node:myAttribute
available using myNode.$myAttribute
.
CDATA sections
or text nodes
(comments
are ignored).CDATA sections
or text nodes
(comments
are ignored).CDATA sections
and text nodes
.
CDATA section
nor a text node
.public Map<String,Object> getMap(String xpath, Node context)
IXPath
Map
, by using IXPath.toMap(Node)
. If no node
could be resolved with the given XPath, null
will be returned.public Map<String,Object> getMap(String xpath)
IXPath
Map
, by using IXPath.toMap(Node)
. If no node
could be resolved with the given XPath, null
will be returned.public List<Map<String,Object>> getMaps(String xpath, Node context)
IXPath
List
of Map
, by using
IXPath.toMap(Node)
in each of these nodes. If no node could be resolved with the given XPath, an empty list
will be returned.public List<Map<String,Object>> getMaps(String xpath)
IXPath
List
of Map
, by using
IXPath.toMap(Node)
in each of these nodes. If no node could be resolved with the given XPath, an empty list
will be returned.LumisXP 12.3.0.200408 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.