Interface IXmlNode
-
- All Known Implementing Classes:
XmlNode
,XmlNodeList
,XmlNullNode
public interface IXmlNode extends Iterable<IXmlNode>
Xml node reader interface
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
attribute(String name)
Try to read value of node attribute with nameboolean
exist()
Returns whether this node exists in the xml.IXmlNode
get(int index)
get child of current xml node at index positionIXmlNode
get(String name)
get all child nodes of current xml node with specific nameIXmlNode
get(String name, int index)
get child node of current xml node with specific name at index positionIXmlNode
getChildren()
get children nodes of current xml nodeString
getName()
String
lookupNamespaceURI(String prefix)
Look up the namespace URI associated to the given prefix, starting from this node.String
path()
int
size()
String
text()
Try to read text content of xml nodevoid
toModel(String attributeName, org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EStructuralFeature feature, Version version, IXmlReadErrorCollector errorCollector)
Try to set attribute of current node in modelvoid
toModel(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EStructuralFeature feature, Version version, IXmlReadErrorCollector errorCollector)
Try to set text of current node in modelIXmlNode
withPartReader(IXmlPartReader partReader)
Get handle to this xml node with custom part readerString
xml()
Returns the text content of this node and its descendants-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Field Detail
-
ALL_NODES
static final String ALL_NODES
Constant to get all nodes- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
String getName()
- Returns:
- name of this node
-
attribute
String attribute(String name)
Try to read value of node attribute with name- Parameters:
name
- of node attribute- Returns:
- value of node attribute with name, or value of first in list nodes attribute with name, or null if node or attribute with specific name not exist
-
text
String text()
Try to read text content of xml node- Returns:
- text content of xml node, or text content of first in list xml nodes, or null if node not exist or can't content text
-
xml
String xml()
Returns the text content of this node and its descendants- Returns:
- the text presentation of this node or empty string if this node does not exist
-
path
String path()
- Returns:
- path to current position in the document, never
null
-
size
int size()
- Returns:
- count of node with specific name
for example:
<Doc> <Page>1</Page> <Page>2</Page> <Page>3</Page> </Doc> rootXmlNode.get("Doc").size(); // = 1 rootXmlNode.get("Doc").get("Page").size(); // = 3 rootXmlNode.get("Doc").get("FireSword").size(); // = 0
-
get
IXmlNode get(int index)
get child of current xml node at index position- Parameters:
index
- of child node- Returns:
- cached and get
IXmlNode
child node
-
get
IXmlNode get(String name)
get all child nodes of current xml node with specific name- Parameters:
name
- of child nodes- Returns:
- cached and get
IXmlNode
child nodes with specific name
-
get
IXmlNode get(String name, int index)
get child node of current xml node with specific name at index position- Parameters:
name
- of child nodeindex
- of child node- Returns:
- cached and get
IXmlNode
child nodes with specific name
-
getChildren
IXmlNode getChildren()
get children nodes of current xml node- Returns:
- cached and get
IXmlNode
children nodes
-
exist
boolean exist()
Returns whether this node exists in the xml.- Returns:
true
if the node exists, otherwisefalse
-
toModel
void toModel(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EStructuralFeature feature, Version version, IXmlReadErrorCollector errorCollector)
Try to set text of current node in model- Parameters:
context
-EObject
feature
-EStructuralFeature
version
- the version of importing 1C:Enterprise XML files, cannot benull
errorCollector
-IXmlReadErrorCollector
in which will be added error if it occur
-
toModel
void toModel(String attributeName, org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EStructuralFeature feature, Version version, IXmlReadErrorCollector errorCollector)
Try to set attribute of current node in model- Parameters:
attributeName
- the attribute name of this node to set in modelcontext
-EObject
feature
-EStructuralFeature
version
- the version of importing 1C:Enterprise XML files, cannot benull
errorCollector
-IXmlReadErrorCollector
in which will be added error if it occur
-
withPartReader
IXmlNode withPartReader(IXmlPartReader partReader)
Get handle to this xml node with custom part reader- Parameters:
partReader
- theIXmlPartReader
to read node, cannot benull
- Returns:
- new instance of
IXmlNode
with specifedIXmlPartReader
for read this node hierarchy, nevernull
-
lookupNamespaceURI
String lookupNamespaceURI(String prefix)
Look up the namespace URI associated to the given prefix, starting from this node.- Parameters:
prefix
- The prefix to look for. If this parameter isnull
, the method will return the default namespace URI if any.- Returns:
- the associated namespace URI or
null
if none is found or this node not exist
-
-