How to get rid of result-document href in generated a href?

Here should go questions about transforming XML with XSLT and FOP.
H2O
Posts: 9
Location: France

How to get rid of result-document href in generated a href?

Mon Dec 19, 2005 9:59 pm

Hello dears,

I'm quite new to Xslt and I'm trying to generate a complete html web site.Datas are enclosed in the XML file and I started by generating each /directory/page.htm one by one. Expecting something a little bit more "industrial" I googled and found two solutions : extensions with xslt 1.0 and the xslt2.0 result-document element. I was not able to set-up xslt1.0 with an appropriate extension in oxygen6.2 so I switched to xslt2.0 and the <xslt:result-document/> element, and Saxon8B.

The xslt file look like this :

Code: Select all

xsl:template match="/">
                                <xsl:for-each select="  //page | //page-rubr | //page-sous-rubr">
                 <xsl:variable name="vrepertoire" select="ancestor::chapitre/repertoire-chap"></xsl:variable>
                <xsl:variable name="extension" select=" '.htm' "></xsl:variable>
                <xsl:result-document  href="{$vrepertoire}/{.}{$extension}" />
<!-- ....code code ... code  content generating OK-->
<!-- sidebar generating for the current page  .... -->
 <xsl:for-each select="rubrique">
                                    <li>
                                        <a>
                                            <xsl:attribute name="href">
                                              <xsl:value-of select="page-rubr"/><xsl:text>.htm</xsl:text>
                                            </xsl:attribute>
                                             <xsl:value-of select="titre-rubr"/>
                                        </a>
                                    </li>
                                </xsl:for-each>



And whatever I tried, for all <a/> generated elements, I can't control the <a href=""> attribute and get a {$vrepertoire} prefixe in every <a/> generated element.:x

I guess this is a known issue, but could not find information on the subject.

http://www.w3.org/TR/xslt20/#terminology
It will often be the case that one final result tree contains links to another final result tree produced during the same transformation, in the form of a relative URI. The mechanism of associating a URI with a final result tree has been chosen to allow the integrity of such links to be preserved when the trees are serialized.


Do you dears have any clue ?
Thank you for reading !
loving being a human being
george
Site Admin
Posts: 2100

Tue Dec 20, 2005 12:35 pm

Hi,

It is hard to say what is wrong as looking at the sample code you posted I cannot see any noticeable problem. You should check the content of the $vrepertoire variable after you compute it, for that you can either use the oXygen XSLT debugger or print the value with an xsl:message instruction.

For XSLT 1.0 there is a sample of writing to multiple files in oXygen/frameworks/xs3p where we extended the XS3P schema documentation stylesheet to generate chunks, for that we used the a stylesheet module from DocBook that provides a template that writes the file to disk and handles more XSLT 1.0 processors extensions (Xalan, Saxon, etc.).

Best Regards,
George
H2O
Posts: 9
Location: France

Tue Dec 20, 2005 12:51 pm

Thank you very much for your fast response George, I gonna try your advises
loving being a human being
H2O
Posts: 9
Location: France

Resolved

Thu Dec 22, 2005 5:25 pm

hello George,

Tried the debugger, it's a great tool.

The reason of the problem I met, I think, is that the generated links were relative to the uri of the generated page, wich was already in a directory, so when the generated links should have been :
<a href="generatedLinkDirectory/file.htm />,
And what was outputed was actually ;
<a href="GeneratedePageURI/generatedLinkDirectory/file.htm/>

Adding an empty variable solved this problem :
<a class="niv0" href="{concat($cfdu,'/',$pageCourante)}">

Thank you for your help :)
loving being a human being

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 0 guests