[forge-issues] [JBoss JIRA] (FORGE-2293) Forge XML parser - Add api so you can insert a child node at a given index

Claus Ibsen (JIRA) issues at jboss.org
Mon Mar 23 11:16:20 EDT 2015


     [ https://issues.jboss.org/browse/FORGE-2293?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen closed FORGE-2293.
------------------------------
    Resolution: Duplicate Issue


> Forge XML parser - Add api so you can insert a child node at a given index
> --------------------------------------------------------------------------
>
>                 Key: FORGE-2293
>                 URL: https://issues.jboss.org/browse/FORGE-2293
>             Project: Forge
>          Issue Type: Feature Request
>          Components: Parsers / File Manipulation
>    Affects Versions: 2.15.2.Final
>            Reporter: Claus Ibsen
>
> I am using the nice XMLParser API from
> https://github.com/forge/xml-parser
> But having a Node, I need to add a new child node at a specific order. Today the child node is added at the end. But my XSD has a structure so I must add the child node at a given position.
> I cannot find an api to do that. I may have to remove all child nodes, and rebuild the structure in the order I need. But I think that is a bit drastic - would be nice if there was an api to do that.
> For example a addSibling method that creates a sibling node, and inserts it just after current node, eg
> If the children is
> A,B,C,D,E,F
> And then I want to add a C2, I can do
>   Node c = ...
>    c.addSibling("C2);
> And then we have
> A,B,C,C2,D,E
> {code}
> Node camel = ...
> for (Node child : camel.getChildren()) {
>     ...
>     logic here
>     if (yeah) {
>       Node newEndpoint = child.addSibiling("endpoint);
>       newEndpoint.attribute("id", "foo");
>       newEndpoint.attribute("url", "bla bla");
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.11#6341)


More information about the forge-issues mailing list