Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: I've read up on XML, but how to really use it?? >Thread Next - Re: I've read up on XML, but how to really use it?? Re: I've read up on XML, but how to really use it??To: NULL Date: 6/8/2006 12:50:00 PM Peter Flynn wrote: > Stan R. wrote: >> One more question if I may. From what I've gathered, usually you >> include the XSLT template right into your main xml doc you're >> working with, a la: >> >> <?xml version="1.0" encoding="ISO-8859-1"?> >> <?xml-stylesheet type="text/xsl" href="test.xsl"?> > > If you want to try and have it rendered in the browser, yes. > Or if you simply want to record for others the location of a > stylesheet. But if you want to use multiple style sheets for one xml, it maybe better to perhaps leave a simple comment <!-- for HTML, use test_html.xsl --> ... And just use an xslt processor (xsltproc.) I assume this would be a good way? >> My question is, is it possible to have the main xml doc in one file >> (say, main.xml), but have a seperate xml file for the transformations >> (include both a XSLT and the main.xml document.) > > In theory, yes, but not practically. > >> This would seem to make more sense to me, as you would have one file >> containing your xml data, and thne have seperate xml files, each >> including the main.xml, but different XSLT files. > > But then you'd have three separate copies of your document to > maintain. That way madness lies. No no no, one main xml with the actual data/layout, and one dtd or xsd, and then seperate xsl files containing differnet templates for different things, which I've discovered xsltproc does a good job of. For instance: $ xmllint --noout --schema test.xsd test.xml test.xml validates $ xsltproc -o test.html test_html.xsl test.xml $ xsltproc -o test.foo test_foo.xsl test.xml $ xsltproc -o test.bar test_bar.xsl test.xml ... > Why not just put three xml-stylesheet Processing Instructions into one > copy of main.xml? Browsers don't honour that, at the moment, AFAIK, > despite having been asked to support variant stylesheets for the best > part of a decade. > >> Say, you have one template for html output, and another for plain >> text, and another for some other format. >> >> From everything I've found online thus far, it seem including xml >> files in other xml files isn't a very clear topic, but it seems to >> me it should be an essential part if you want to keep things >> seperate and organized, unless I'm really missing something here. > > No-one has ever asked to do it. The alternative is to have your three > stylesheets, but run them on a dummy 1-line XML file, and use the > document('main.xml') function to reference your main document, so that > it gets included for processing. In XLST2, you don't even need the > dummy file. How do you use the document('main.xml') ? -- Stan | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
