Connecting Tech Pros Worldwide Forums | Help | Site Map

*Very* basic XML/XSL question...

Tom
Guest
 
Posts: n/a
#1: Jul 20 '05
Hey all,

I've been planning to get myself started with DocBook for quite some
time now, so when I unexpectedly encountered a task for which DocBook
might actually be very useful, I thought I'd no longer wait.

Some Googling pointed me to several beginner tutorials, and I chose to
get myself going with the guide at

http://rzserv2.fhnon.de/%7Elg002556/docbuch/

However, as soon as I hit the very first example, my enthusiasm quickly
faded away, since I can't get it to work properly, "as advertised", so
to say. The tutorial is in German, but that doesn't matter: at 1.2, the
reader is shown a really basic xml file, referring to some docbook.xls
file for it's styling. A screenshot shows what the result should look
like in a browser.

The author puts this in his xml file

<?xml-stylesheet type="text/xsl"
href="file://C:/x/docbookxsl/docbook-xsl-1.55.0/xhtml/docbook.xsl" ?>

I don't run Windows, so on my machine, the path to that xsl file
is /usr/share/xml/docbook/stylesheet/nwalsh/xthml/docbook.xsl. I've
tried every possible way to link to it from the xml file (file:///,
just /usr/..., climbing up the tree like ../../../....., in the end I
even put the whole docbook tree next to the file), but nothing works
(and yes, the file is readable by regular users). All I get is plain
tags. I fiddled around with the mimetype too (text/xml, text/xsl,
application/xml, application/xml+xsl) and tried serving it with apache,
all too no avail. On IRC, some kind people pointed me to some more
general, i.e. not specificly DocBook-related tutorials, which I
definitely plan to go through.

But still, I was wondering if I've got this straight: the data one
describes using XML, dictated by a DocBook DTD, should be *styled* by
an xsl file, right? Why, then, doesn't the above example, used in a
DocBook tutorial from someone who seems to know a lot about it, seem to
work? Wouldn't it be obvious what purposes a file called "docbook.xsl",
inside a directory called "xhtml", that is somewhere in a tree
underneath "stylesheets", could possible serve?

I'm a little confused, and since no-one on IRC could give me any direct
clue about it, I'm hoping the question is not *that* superfluous. I
apologize sincerely if it was.

Greets,
Tom

--
"Mongolian drivers do not care much about pedestrians."
--
np: Welle: Erdball - Die Moorsoldaten (flac)


Matt
Guest
 
Posts: n/a
#2: Jul 20 '05

re: *Very* basic XML/XSL question...


This example was probably intended to be run under MS Internet
Explorer. The xml-stylesheet directive tells the parser that this XML
doc should be transformed using the XSL doc indicated (note that XSL
transforms one XML document into a different XML document - it doesn't
simply 'style' it. In this case, it is probably transforming plain
XML into docbook format). If you are running the XML through a parser
that doesn't recognise the xml-stylesheet directive, they you won't
get the transformation. I suggest that you do the transformation
manually for each example. There are tons of tools around that will
allow you to do it from the command line.


Tom <tom @ abwaerts . be> wrote in message news:<8846578.Jl1bF0PiBf@zukunft.mine.nu>...[color=blue]
> Hey all,
>
> I've been planning to get myself started with DocBook for quite some
> time now, so when I unexpectedly encountered a task for which DocBook
> might actually be very useful, I thought I'd no longer wait.
>
> Some Googling pointed me to several beginner tutorials, and I chose to
> get myself going with the guide at
>
> http://rzserv2.fhnon.de/%7Elg002556/docbuch/
>
> However, as soon as I hit the very first example, my enthusiasm quickly
> faded away, since I can't get it to work properly, "as advertised", so
> to say. The tutorial is in German, but that doesn't matter: at 1.2, the
> reader is shown a really basic xml file, referring to some docbook.xls
> file for it's styling. A screenshot shows what the result should look
> like in a browser.
>
> The author puts this in his xml file
>
> <?xml-stylesheet type="text/xsl"
> href="file://C:/x/docbookxsl/docbook-xsl-1.55.0/xhtml/docbook.xsl" ?>
>
> I don't run Windows, so on my machine, the path to that xsl file
> is /usr/share/xml/docbook/stylesheet/nwalsh/xthml/docbook.xsl. I've
> tried every possible way to link to it from the xml file (file:///,
> just /usr/..., climbing up the tree like ../../../....., in the end I
> even put the whole docbook tree next to the file), but nothing works
> (and yes, the file is readable by regular users). All I get is plain
> tags. I fiddled around with the mimetype too (text/xml, text/xsl,
> application/xml, application/xml+xsl) and tried serving it with apache,
> all too no avail. On IRC, some kind people pointed me to some more
> general, i.e. not specificly DocBook-related tutorials, which I
> definitely plan to go through.
>
> But still, I was wondering if I've got this straight: the data one
> describes using XML, dictated by a DocBook DTD, should be *styled* by
> an xsl file, right? Why, then, doesn't the above example, used in a
> DocBook tutorial from someone who seems to know a lot about it, seem to
> work? Wouldn't it be obvious what purposes a file called "docbook.xsl",
> inside a directory called "xhtml", that is somewhere in a tree
> underneath "stylesheets", could possible serve?
>
> I'm a little confused, and since no-one on IRC could give me any direct
> clue about it, I'm hoping the question is not *that* superfluous. I
> apologize sincerely if it was.
>
> Greets,
> Tom
>
> --
> "Mongolian drivers do not care much about pedestrians."[/color]
Tom
Guest
 
Posts: n/a
#3: Jul 20 '05

re: *Very* basic XML/XSL question...


[Sunday 29 February 2004 23:50] Matt in comp.text.xml:
[color=blue]
> This example was probably intended to be run under MS Internet
> Explorer. The xml-stylesheet directive tells the parser that this XML
> doc should be transformed using the XSL doc indicated (note that XSL
> transforms one XML document into a different XML document - it doesn't
> simply 'style' it. In this case, it is probably transforming plain
> XML into docbook format).[/color]

Hey hey... I think you managed to make it clear to me what I was trying
to do and why it didn't work.

Let me get this straight: the XML document one writes, using a DocBook
DTD, can be transformed to any kind of output document by means of
specific XSL documents, designed for the purpose? But what, then, is
"DocBook"? Just a bunch of predescribed tags, that can be used to
efficiently write documentation of many kinds?
[color=blue]
> If you are running the XML through a parser
> that doesn't recognise the xml-stylesheet directive, they you won't
> get the transformation. I suggest that you do the transformation
> manually for each example. There are tons of tools around that will
> allow you to do it from the command line.[/color]

Yes, thanks.

Still, I wonder: why, then, did the example obviously work in Internet
Explorer, and not in Mozilla, Konqueror, or whatever browser I tried?
Is that determined by some browser-specific XML parser, which, in the
case of IE, managed to interpret the stylesheet on the fly?

Greets, and many thanks,
Tom

--
"Mongolian drivers do not care much about pedestrians."
--
np: gar nix

Patrick TJ McPhee
Guest
 
Posts: n/a
#4: Jul 20 '05

re: *Very* basic XML/XSL question...


In article <2824460.nRqGbdzLkF@zukunft.mine.nu>, Tom <tom@verbreyt.be> wrote:

% specific XSL documents, designed for the purpose? But what, then, is
% "DocBook"? Just a bunch of predescribed tags, that can be used to
% efficiently write documentation of many kinds?

Not `Just a bunch', but `A bunch'.

% Still, I wonder: why, then, did the example obviously work in Internet
% Explorer, and not in Mozilla, Konqueror, or whatever browser I tried?

If it didn't work in Mozilla, it may be that the stylesheet doesn't
use the correct URL for the name space prefix. IE accepts two -- the
correct one, http://www.w3.org/1999/XSL/Transform, and another one
which only it accepts. There are many browsers out there, of which
only some can handle xslt.

--

Patrick TJ McPhee
East York Canada
ptjm@interlog.com
Matt
Guest
 
Posts: n/a
#5: Jul 20 '05

re: *Very* basic XML/XSL question...


XML directives (tags starting with <?) are not actually a part of the
XML document, but are instructions to the parser. In this case, the
instruction to the parser is to transform the document with the given
XSL doc. Directives rely on the parser recognising them, and off the
top of my head, I think the only directive that a parser MUST
recognise is <?xml ...?>. If a parser doesn't recognise a directive,
it just ignores it. I think (and may be wrong) that IE is the only
browser that supports the stylesheet directive.

I hope this makes things clearer for you.

Matt

ptjm@interlog.com (Patrick TJ McPhee) wrote in message news:<c1vl21$dvj$1@news.eusc.inter.net>...[color=blue]
> In article <2824460.nRqGbdzLkF@zukunft.mine.nu>, Tom <tom@verbreyt.be> wrote:
>
> % specific XSL documents, designed for the purpose? But what, then, is
> % "DocBook"? Just a bunch of predescribed tags, that can be used to
> % efficiently write documentation of many kinds?
>
> Not `Just a bunch', but `A bunch'.
>
> % Still, I wonder: why, then, did the example obviously work in Internet
> % Explorer, and not in Mozilla, Konqueror, or whatever browser I tried?
>
> If it didn't work in Mozilla, it may be that the stylesheet doesn't
> use the correct URL for the name space prefix. IE accepts two -- the
> correct one, http://www.w3.org/1999/XSL/Transform, and another one
> which only it accepts. There are many browsers out there, of which
> only some can handle xslt.[/color]
Alain Frisch
Guest
 
Posts: n/a
#6: Jul 20 '05

re: *Very* basic XML/XSL question...


Matt (comp.text.xml:60416):[color=blue]
> XML directives (tags starting with <?) are not actually a part of the
> XML document, but are instructions to the parser. In this case, the
> instruction to the parser is to transform the document with the given
> XSL doc. Directives rely on the parser recognising them, and off the
> top of my head, I think the only directive that a parser MUST
> recognise is <?xml ...?>. If a parser doesn't recognise a directive,
> it just ignores it.[/color]

Well, not quite. The XML spec does not specify at all what parsers
should return, only what they accept. Some parsers may return processing
instructions.

Now, you also have document models, such as XPath's. And as a matter of
fact, processing instructions *are* part of this document model (so you'd
better use a parser that returns processing instructions to
"load" this document model...). Btw, the same applies to comments: it's
possible to write an XSLT stylesheet whose result depends on the content
of some comment in the input document. XML is a wonderful world ;-)
Patrick TJ McPhee
Guest
 
Posts: n/a
#7: Jul 20 '05

re: *Very* basic XML/XSL question...


In article <e0c2544d.0403011438.437bd3eb@posting.google.com >,
Matt <matt@realdevelopments.com.au> wrote:

% XML directives (tags starting with <?) are not actually a part of the
% XML document, but are instructions to the parser.

OK, but Mozilla understands the xsl-stylesheet PI, so, in the absence of
more accurate information, we are free to speculate on the reasons
Mozilla might not be transforming the document -- one possible reason
would be a stylesheet which doesn't use the correct name space
declaration. A useful, informative, follow-up to my posting would have
told us the declaration that IE accepts but no other XSLT processor
does. Perhaps we'll have one of those tomorrow.
--

Patrick TJ McPhee
East York Canada
ptjm@interlog.com
Derek Harmon
Guest
 
Posts: n/a
#8: Jul 20 '05

re: *Very* basic XML/XSL question...


"Patrick TJ McPhee" <ptjm@interlog.com> wrote in message news:c2106v$rkp$1@news.eusc.inter.net...[color=blue]
> OK, but Mozilla understands the xsl-stylesheet PI,[/color]

It's the xml-stylesheet PI, and it's been a W3C Recommendation
for close to five years,

http://www.w3.org/TR/xml-stylesheet/

although IE and Mozilla are the only two browsers I know of that
have any sort of implementation for this.
[color=blue]
> A useful, informative, follow-up to my posting would have
> told us the declaration that IE accepts but no other XSLT processor
> does.[/color]

You don't mean,

http://www.w3.org/TR/WD-xsl

do you? There's nothing Microsoft-specific about it; it was just the old
XSL namespace URI when it was still a Working Draft. MSXML accepts
it for compatibility with legacy stylesheets that do not require XSLT 1.0
conformance.


Derek Harmon


Patrick TJ McPhee
Guest
 
Posts: n/a
#9: Jul 20 '05

re: *Very* basic XML/XSL question...


In article <c212f7$1mpcjl$1@ID-185805.news.uni-berlin.de>,
Derek Harmon <loresayer@email.msn.com> wrote:
% "Patrick TJ McPhee" <ptjm@interlog.com> wrote in message
% news:c2106v$rkp$1@news.eusc.inter.net...
% > OK, but Mozilla understands the xsl-stylesheet PI,
%
% It's the xml-stylesheet PI, and it's been a W3C Recommendation
% for close to five years,

Oops -- sorry. wrt to browser support, there's nothing wrong with not
understanding any PI at all, but when you're diagnosing a problem, you
need to know whether the tools you use do understand the PIs you're
using.

% You don't mean,
%
% http://www.w3.org/TR/WD-xsl
%
% do you? There's nothing Microsoft-specific about it; it was just the old
% XSL namespace URI when it was still a Working Draft. MSXML accepts

I didn't say it was Microsoft-specific. I said that only IE accepts it.
I guess we could expand it to include any browser or other tool that
uses MSXML. The question here is why something works in IE, but not in
other browsers. The most obvious reasons are that the other browsers
don't provide xslt (but we know Mozilla does), and that IE accepts a
stylesheet name space declaration that other XSLT processors don't.

To the OP, if you have something like

<xsl:stylesheet xmlns:xsl='http://www.w3.org/TR/WD-xsl' ...>

then change it to

<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' ...>

and you may find it works with Mozilla, and any other browsers that
support XSLT, as well as IE.

--

Patrick TJ McPhee
East York Canada
ptjm@interlog.com
Tom
Guest
 
Posts: n/a
#10: Jul 20 '05

re: *Very* basic XML/XSL question...


[Tuesday 02 March 2004 17:51] Patrick TJ McPhee in comp.text.xml:

<snip>

A little late, but thanks to all. I'm still trying to get the big
picture, but I'm sure I'll get the hang of it. Eventually. :-)

Greets,
Tom

--
"Mongolian drivers do not care much about pedestrians."
--
np: Lapsed - Twilight (13) (flac)

Closed Thread