You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Ulrico Canzi (ERGO SUM)" <ca...@ergosum.it> on 2000/08/15 11:43:24 UTC

BUG: Xalan does not manage document fragments variables

I need to process the same xml file several times in order to present
different statistics and reports in a html page.

I use a docfragment <xsl:variable> to describe what statistics i wont.
All works fine with IE5.0 + MSXML3 (June 2000) and with XmlSpy 3.0, but
Xalan is not able to process my stylesheet.

To make things easier to undersand, istead to enclose my original files
I enclosed two very simple files (x.xml and x.xsl) that
are able to produce the Xalan error.


--- COMMAND LINE 
-------------------------------------------------------------------

java org.apache.xalan.xslt.Process -IN x.xml -XSL x.xsl -OUT x.html


--- XALAN ERROR MESSAGE 
------------------------------------------------------------

========= Parsing file:E:/VPN/x.xsl ==========
Parse of file:E:/VPN/x.xsl took 2580 milliseconds
========= Parsing file:E:/VPN/x.xml ==========
Parse of file:E:/VPN/x.xml took 220 milliseconds
=============================
Transforming...
XPATH: Can not convert #RTREEFRAG to a NodeList!
Xalan: was not successful.
XSLProcessor: done


--- FILE x.xml 
----------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="x.xsl"?>
<nums>
   <n>10</n>
   <n>20</n>
   <n>30</n>
</nums>



--- FILE x.xsl 
----------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="chars" >
   <c val="A" />
   <c val="B" />
</xsl:variable>

<xsl:variable name="curdoc" select="/" />

<xsl:template match="/">
   <html><body>
     <xsl:for-each select="$chars/c">
       <h1><xsl:value-of select="@val" /></h1>
         <xsl:apply-templates select="$curdoc//n" />
     </xsl:for-each>
   </body></html>
</xsl:template>

<xsl:template match="n">
    <p><xsl:value-of select="." /></p>
</xsl:template>

</xsl:stylesheet>


--- Expected result (x.html) 
---------------------------------------------------------

<html>
   <body>

    <h1>A</h1>

    <p>10</p>
    <p>20</p>
    <p>30</p>

    <h1>B</h1>

    <p>10</p>
    <p>20</p>
    <p>30</p>

   </body>
</html>

-----------------------------------------------------------------------
Ing. Ulrico Canzi
-----------------------------------------------------------------------
ERGO SUM (Consulenza - Formazione - Sviluppo Software)
Via Ceriani 64
21040 Uboldo (VA)
ITALY

Tel 02-96789182    Fax 02-96782607
EMail: canzi@ergosum.it
http://www.ergosum.it/


two stylesheets in an XML document?

Posted by Dave <LI...@sheffield.ac.uk>.
Hi,
I am quite new to Xalan.
I am using the DefaultApplyXSL servlet and trying to include 
two <?xml-stylesheet ... > in an XML document, one for WML 
and the other for HTML, i.e.:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet  
href="http://localhost/project.nsf/workHtml.xsl?OpenPage" 
type="text/xsl"?>
<?xml-stylesheet  alternate="yes" 
href="http://localhost/project.nsf/workWml.xsl?OpenPage" 
type="text/xsl" media="up"?>
.....

But, this does not work. 
When I include only one <?xml-stylesheet ...>, it works well.
So, I think each stylesheet is all right.
Is this a stupid question?
Or are there any other ways to get around this?
I tried to access the mail list for answers but, it was impossible.

Waiting for guru's answers...

Thanks.

Dave

Re: BUG: Xalan does not manage document fragments variables

Posted by Gary L Peskin <ga...@firstech.com>.
Ulrico --

Xalan is actually in compliance with the XSLT standard (section 11.1)
while MSXML3 is not.
Your "docfragment" is actually called a "result tree fragment" and this
is what is bound to the variable "chars".

Regarding your statement:

	<xsl:for-each select="$chars/c">

the standard states "It is not permitted to use the /, //, and []
operators on result tree fragments.  This is why Xalan complains.

To convert the result tree fragment to a node-set, use the nodeset
extension function present in the latest version of Xalan.  If you need
help using the nodeset extension function, just let us know.

Gary

"Ulrico Canzi (ERGO SUM)" wrote:
> 
> I need to process the same xml file several times in order to present
> different statistics and reports in a html page.
> 
> I use a docfragment <xsl:variable> to describe what statistics i wont.
> All works fine with IE5.0 + MSXML3 (June 2000) and with XmlSpy 3.0, but
> Xalan is not able to process my stylesheet.
> 
> To make things easier to undersand, istead to enclose my original files
> I enclosed two very simple files (x.xml and x.xsl) that
> are able to produce the Xalan error.
> 
> --- COMMAND LINE
> -------------------------------------------------------------------
> 
> java org.apache.xalan.xslt.Process -IN x.xml -XSL x.xsl -OUT x.html
> 
> --- XALAN ERROR MESSAGE
> ------------------------------------------------------------
> 
> ========= Parsing file:E:/VPN/x.xsl ==========
> Parse of file:E:/VPN/x.xsl took 2580 milliseconds
> ========= Parsing file:E:/VPN/x.xml ==========
> Parse of file:E:/VPN/x.xml took 220 milliseconds
> =============================
> Transforming...
> XPATH: Can not convert #RTREEFRAG to a NodeList!
> Xalan: was not successful.
> XSLProcessor: done
> 
> --- FILE x.xml
> ----------------------------------------------------------------------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl" href="x.xsl"?>
> <nums>
>    <n>10</n>
>    <n>20</n>
>    <n>30</n>
> </nums>
> 
> --- FILE x.xsl
> ----------------------------------------------------------------------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:variable name="chars" >
>    <c val="A" />
>    <c val="B" />
> </xsl:variable>
> 
> <xsl:variable name="curdoc" select="/" />
> 
> <xsl:template match="/">
>    <html><body>
>      <xsl:for-each select="$chars/c">
>        <h1><xsl:value-of select="@val" /></h1>
>          <xsl:apply-templates select="$curdoc//n" />
>      </xsl:for-each>
>    </body></html>
> </xsl:template>
> 
> <xsl:template match="n">
>     <p><xsl:value-of select="." /></p>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> --- Expected result (x.html)
> ---------------------------------------------------------
> 
> <html>
>    <body>
> 
>     <h1>A</h1>
> 
>     <p>10</p>
>     <p>20</p>
>     <p>30</p>
> 
>     <h1>B</h1>
> 
>     <p>10</p>
>     <p>20</p>
>     <p>30</p>
> 
>    </body>
> </html>
> 
> -----------------------------------------------------------------------
> Ing. Ulrico Canzi
> -----------------------------------------------------------------------
> ERGO SUM (Consulenza - Formazione - Sviluppo Software)
> Via Ceriani 64
> 21040 Uboldo (VA)
> ITALY
> 
> Tel 02-96789182    Fax 02-96782607
> EMail: canzi@ergosum.it
> http://www.ergosum.it/