Interesting Little Mystery for a Beginner

Here should go questions about transforming XML with XSLT and FOP.
TimP
Posts: 7
Joined: Mon Jun 30, 2008 9:52 pm

Interesting Little Mystery for a Beginner

Post by TimP »

I've tried to write a little XSLT (v 1.0) spec for digging the names of multiple authors out of the info section of a docbook (v5.0) document. I first got a couple little samples working fine. Yet, I just couldn't seem to get the xsl to traverse the list of authors in the docbook document. So, I pared the document back to include just the info section and then removed the schema identifier to make it look like just a specless xml doc. Then the transformation worked fine. All the document tags are exactly the same. Hmmm. Here's the xsl source. Can anybody suggest why this would work without the schema identifier in the document but not with it?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<h2>Article Contributors</h2>
<xsl:for-each select="article/info/authorgroup/author/personname">
<p><xsl:value-of select="firstname"/> <xsl:value-of select="surname"/></p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Interesting Little Mystery for a Beginner

Post by sorin_ristache »

Hello,

What do you mean you removed the schema identifier? Is it a DocBook 5 document and does the XSLT transform work when you remove the namespace declaration? It could be a namespace problem in the stylesheet. Do you match in your XSLT stylesheet on the right Docbook element names from the right namespace?


Regards,
Sorin
TimP
Posts: 7
Joined: Mon Jun 30, 2008 9:52 pm

Re: Interesting Little Mystery for a Beginner

Post by TimP »

Competence is such a marvelous thing. Yes, indeed, removing the namespace declaration from the docbook doc makes the xsl spec function as expected (although the oXygen editor's validator doesn't much like the article element anymore).

The question remains as to how to properly refer to a given namespace from within an xsl document, but it is moot at this point. I should attempt to answer this myself having been given the excellent clue, and, my original intention was not to build a standalone transformation, but to experiment with embellishing the cover page generated from docbook documents. As far as it goes, the experiment is now successful.

Thank you, Sorin, for your help.
Post Reply