homepage Welcome to WebmasterWorld Guest from
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

xml file within an xml file

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

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>

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)

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)

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)

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)

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]

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