xsl-list
[Top] [All Lists]

Adding Missing Elements

2005-09-13 09:01:35
Hello,

I wanted to get some opinions on the best way of doing something in xsl.

I have an element <node> which has a certain set of attributes and child
nodes that will always be there.  However, it has an additional <list>
child element, that may or may not be present with varying child
elements so <node> could have variations like this...

<wrapper>
        <node id1="5" id2="bar">
                <name>myname</name>
                <value>myvalue</value>
        </node>
</wrapper>

<wrapper>
        <node id1="5" id2="bar">
                <list/>
                <name>myname</name>
                <value>myvalue</value>
        </node>
</wrapper>

<wrapper>
        <node id1="5" id2="bar">
                <list>
                        <item>A</item>
                </list>
                <name>myname</name>
                <value>myvalue</value>
        </node>
</wrapper>

<wrapper>
        <node id1="5" id2="bar">
                <list>
                        <item>A</item>
                        <item>B</item>
                </list>
                <name>myname</name>
                <value>myvalue</value>
        </node>
</wrapper>

Given these possible variations and based on some processing elsewhere
in the document, I would like to make sure that <node> always has
<item>B</item> in its list...possibly adding <list> if it is not
present.

Can someone give me some suggestions on the best way to do this?

Thanks,

Matt

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>