Welcome to WebmasterWorld Guest from 107.20.20.39

Forum Moderators: httpwebwitch

Message Too Old, No Replies

xml file within an xml file

   
2:19 am on Dec 9, 2008 (gmt 0)

5+ Year Member



Me again. Thanks so much for your help last time. New question -
Is it possible to pull one xml document into another - in a way that it can be transformed with xslt?
I have tried

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="xstyle.xslt"?>
<content>fascinating stuff</content>
<doc filename="nav.xml"/>
<content>more fascinating stuff</content>
</xml>

and it pulls the contents of nav.xml in as plain text. But what I wanted was to pull it in as xml which can then be formatted with xstyle.xslt. I tried linking nav.xml to an xslt, but that didn't work either.

Is what I'm trying to do even doable? Or is this really simple and I'm messing something up? Thanks!

5:18 am on Dec 9, 2008 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I think this can be done with XSLT2.0... let me consult the Big Red Book and get back to ya
4:07 pm on Dec 9, 2008 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I understand what you're asking... I haven't looked for a way to do it with XSLT yet, because it's not a technique I'd instinctively employ so it's not in my day-to-day arsenal.

Given the same situation I'd parse the XML on the server and inject the extra XML before it's transformed. To wit, grab the XML and load it as a DOM object in PHP. Use XPATH to find all the <doc> elements, and loop through them. For each, get their @filename attribute. Then read the external XML and inject its nodes after (as siblings of) your <doc> element, then remove the <doc> element itself.

One question right off the bat - are you using PHP on the back end? If so, you're limited to using XSLT1, because there's no XSLT2 library for PHP (yet)

Or... are you doing client-side XSLT?

4:41 pm on Dec 9, 2008 (gmt 0)

5+ Year Member



Well.... At this point - early stages of converting an html library to xml - I'm just using client-side xslt.

Eventually I would be using PHP (or something else that's better?) but for now, I was just trying to see what I would need to do to make the library work, how to set it up, etc.

The file I was thinking about making its own xml file is a set of navigation links that would be used on some of the files, but not all.

5:27 pm on Dec 19, 2008 (gmt 0)

10+ Year Member



There's a great article on the redhat XML mailing list that should help:

http://sources.redhat.com/ml/xsl-list/2000-07/msg00477.html [sources.redhat.com]

 

Featured Threads

Hot Threads This Week

Hot Threads This Month