Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: I've read up on XML, but how to really use it??

From: "Stan R." <stan@-------.------------.--->
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 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent