Class XmlNode

    • Constructor Detail

      • XmlNode

        public XmlNode​(Node parent,
                       IXmlPartReader partReader)
        Constructor

        usage example:

         
         Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file);
         IXmlNode rootNode = new XmlNode(doc, BaseXmlPartReaderProvider.INSTANCE);
         
         
        Parameters:
        parent - xml document Node
        partReader - the specifed IXmlPartReader for read this node hierarhy, cannot be null
      • XmlNode

        public XmlNode​(Node parent,
                       String path,
                       IXmlPartReader partReader)
        Constructor
        Parameters:
        parent - xml document Node
        path - from the root node to current, cannot be null
        partReader - the specifed IXmlPartReader for read this node hierarhy, cannot be null
        See Also:
        usage example
    • Method Detail

      • getName

        public String getName()
        Specified by:
        getName in interface IXmlNode
        Returns:
        name of this node
      • attribute

        public String attribute​(String name)
        Description copied from interface: IXmlNode
        Try to read value of node attribute with name
        Specified by:
        attribute in interface IXmlNode
        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

        public String text()
        Description copied from interface: IXmlNode
        Try to read text content of xml node
        Specified by:
        text in interface IXmlNode
        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

        public String xml()
        Description copied from interface: IXmlNode
        Returns the text content of this node and its descendants
        Specified by:
        xml in interface IXmlNode
        Returns:
        the text presentation of this node or empty string if this node does not exist
      • size

        public int size()
        Specified by:
        size in interface IXmlNode
        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
         
         
      • path

        public String path()
        Specified by:
        path in interface IXmlNode
        Returns:
        path to current position in the document, never null
      • get

        public IXmlNode get​(int index)
        Description copied from interface: IXmlNode
        get child of current xml node at index position
        Specified by:
        get in interface IXmlNode
        Parameters:
        index - of child node
        Returns:
        cached and get IXmlNode child node
      • get

        public IXmlNode get​(String name)
        Description copied from interface: IXmlNode
        get all child nodes of current xml node with specific name
        Specified by:
        get in interface IXmlNode
        Parameters:
        name - of child nodes
        Returns:
        cached and get IXmlNode child nodes with specific name
      • get

        public IXmlNode get​(String name,
                            int index)
        Description copied from interface: IXmlNode
        get child node of current xml node with specific name at index position
        Specified by:
        get in interface IXmlNode
        Parameters:
        name - of child node
        index - of child node
        Returns:
        cached and get IXmlNode child nodes with specific name
      • getChildren

        public IXmlNode getChildren()
        Description copied from interface: IXmlNode
        get children nodes of current xml node
        Specified by:
        getChildren in interface IXmlNode
        Returns:
        cached and get IXmlNode children nodes
      • exist

        public boolean exist()
        Description copied from interface: IXmlNode
        Returns whether this node exists in the xml.
        Specified by:
        exist in interface IXmlNode
        Returns:
        true if the node exists, otherwise false
      • lookupNamespaceURI

        public String lookupNamespaceURI​(String prefix)
        Description copied from interface: IXmlNode
        Look up the namespace URI associated to the given prefix, starting from this node.
        Specified by:
        lookupNamespaceURI in interface IXmlNode
        Parameters:
        prefix - The prefix to look for. If this parameter is null, 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
      • toModel

        public void toModel​(org.eclipse.emf.ecore.EObject context,
                            org.eclipse.emf.ecore.EStructuralFeature feature,
                            Version version,
                            IXmlReadErrorCollector errorCollector)
        Description copied from interface: IXmlNode
        Try to set text of current node in model
        Specified by:
        toModel in interface IXmlNode
        Parameters:
        context - EObject
        feature - EStructuralFeature
        version - the version of importing 1C:Enterprise XML files, cannot be null
        errorCollector - IXmlReadErrorCollector in which will be added error if it occur
      • toModel

        public void toModel​(String attributeName,
                            org.eclipse.emf.ecore.EObject context,
                            org.eclipse.emf.ecore.EStructuralFeature feature,
                            Version version,
                            IXmlReadErrorCollector errorCollector)
        Description copied from interface: IXmlNode
        Try to set attribute of current node in model
        Specified by:
        toModel in interface IXmlNode
        Parameters:
        attributeName - the attribute name of this node to set in model
        context - EObject
        feature - EStructuralFeature
        version - the version of importing 1C:Enterprise XML files, cannot be null
        errorCollector - IXmlReadErrorCollector in which will be added error if it occur