homepage Welcome to WebmasterWorld Guest from 54.161.166.171
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
XSLT to convert 2 XML files to 1
Fotiman




msg:3760728
 7:01 pm on Oct 7, 2008 (gmt 0)

It's been years since I've done any XSLT work. Any help appreciated.

I have an XML file that resembles something like this:

<Node> 
<LocationBase url="http://example.com/foo/" />
<Node>
<Item>
<Id>12345</Id>
</Item>
<Item>
<Id>98765</Id>
</Item>
</Node>
</Node>

Each Item represents another XML file located at LocationBase. For example:

http://example.com/foo/12345.xml
and
http://example.com/foo/98765.xml

Those files might look like this:

<folder> 
<list>
<record />
<record />
</list>
<folder>
<list>
<record />
</list>
</folder>
</folder>

Note, in the first example there could be any number of nested Nodes, and in this example there could be any number of nested folders.

Is there a way to combine these (with XLST) into a single structure like this:

<Node> 
<LocationBase url="http://example.com/foo/" />
<Node>
<Item>
<folder>
<list>
<record />
<record />
</list>
<folder>
<list>
<record />
</list>
</folder>
</folder>
</Item>
<Item>
<folder>
...
</folder>
</Item>
</Node>
</Node>

Any input appreciated.

 

httpwebwitch




msg:3760923
 12:43 am on Oct 8, 2008 (gmt 0)

you'll probably need to employ an unusual feature of XSLT2: the document() function which lets you specify a whole external XML file as though it's the current node

reference:
[w3.org...]

example:
<xsl:variable name="doc2" select="document('/foo/12345.xml')" />

Fotiman




msg:3761228
 1:23 pm on Oct 8, 2008 (gmt 0)

Interesting. Thanks! :-)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved