Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Reformat XML

From: "Matt" <mdframe@-------.--------------.--->
To: NULL
Date: 4/1/2005 12:02:00 PM
This is a multi-part message in MIME format.

------=_NextPart_000_0010_01C536B2.AD115500
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have a situation where I am trying to reformat some XML but I do not =
want to use any XML document element name specific information as I am =
trying to write the XSL generically as possible.  I have the following =
XML:

<root>
    <node1/>
    <node2/>
    <node3/>
    <node3/>
    <node3/>
    <node3/>
    <node3/>
    <node4/>
</root>

I want to recursively go throught the tree but when I get to node3 I =
want to place all of them inside a new collection node.  I had thought I =
could create a template and pass it the selection of something like =
following-sibling::*[name(following-sibling::*) =3D name(.)] but that is =
not working.  So the result I am looking for in my output would be:

<root>
    <node1/>
    <node2/>
    <collection>
        <node3/>
        <node3/>
        <node3/>
        <node3/>
        <node3/>
    </collection>
    <node4/>
</root>


 If I hard code the value node3 in the equals it seems to work but that =
defeats my generic-ness of what I am trying to do.  If anyone has any =
suggestions I would appreciate it.

Thanks,=20

Matt
------=_NextPart_000_0010_01C536B2.AD115500
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.3790.259" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>I have a situation where I am trying to =
reformat=20
some XML but I do not want to use any XML document element name specific =

information as I am trying to write the XSL generically as =
possible.&nbsp; I=20
have the following XML:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;root&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node1/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node2/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node3/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node3/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node3/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node3/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node3/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node4/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;/root&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I want to recursively go throught the =
tree but when=20
I get to node3 I want to place all of them inside a new collection =
node.&nbsp; I=20
had thought I could create a template and pass it the selection of =
something=20
like following-sibling::*[name(following-sibling::*) =3D name(.)] but =
that is not=20
working.&nbsp; So the result I am looking for in my output would=20
be:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>&lt;root&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node1/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node2/&gt;</FONT></DIV>
<DIV>&nbsp;&nbsp;&nbsp; &lt;collection&gt;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;node3/&gt;</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&lt;node3/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;node3/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;node3/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&lt;node3/&gt;</FONT></DIV>
<DIV>&nbsp;&nbsp;&nbsp; &lt;/collection&gt;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&lt;node4/&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;/root&gt;</FONT></DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;If I hard code the value node3 in =
the equals=20
it seems to work but that defeats my generic-ness of what I am trying to =

do.&nbsp; If anyone has any suggestions I would appreciate =
it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Matt</FONT></DIV></BODY></HTML>

------=_NextPart_000_0010_01C536B2.AD115500--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent