Forum Moderators: open

Message Too Old, No Replies

Xml to xslt

What is the least painful way to do this?

         

korkus2000

5:20 pm on May 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an xml document like so

<root>
<books>
<stuff>
</stuff>
</books>
<bikes>
<stuff>
</stuff>
</bikes>
<food>
<stuff>
</stuff>
</food>
</root>

each element books, bikes, and food will be translated into 3 seperate pages. They will never be on the same html page. I don't want to split the xml. How can I call xslt for each element depending on what page is called? Do I have to make 1 catch all xslt or can I create 3 that are called?

Im using msxml parser 3.0
I hope this makes sense.

Xoc

5:30 pm on May 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes. Easy enough to do. You make three separate XSLT style sheets that pull out the three pieces you want. You then apply the XSLT to the XML the produce HTML.

I described how to apply the XML/XSLT in this thread: [webmasterworld.com...]

korkus2000

5:33 pm on May 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So should all links to the xml data pages pass through an asp process page that applies the xml to the xslt?

This is web based software that uses only IE as its interface through the browser component in c++. Right now I am just applying the stylesheet on the xml page. I do have access to iis so I can do the asp thing.

Xoc

5:37 pm on May 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes. The ASP page doesn't need to have much on it, just the Server Side Include and a call to the CreateHTMLFromXMLXSLT function.

In .NET it is even simpler. In Visual Studio there is a control that you can just drop on your page and set a couple of properties for the XML and XSLT files you want to use, and it does the work for you. It's a little more complicated than that if you need to pass parameters to the XSLT, but not much more complicated.