Re: [xslt] XInclude-processing in XSL stylesheets



Hi,

Now that you mention the xsl:include, I assume the problem is:
the enabling of the XInclude mechanism for the stylesheets
itself is not channelled through to inclusions of subsequent
stylesheets.

Possible solutions:
1) Add a stylesheet-compiling function to the API, which takes
  options; this would allow to let the Libxslt library itself
  apply the XInclude mechanism on all stylesheets per option.
2) Tweak the document loader in xsltproc.c to be able to
  preprocess stylesheets.
3) Enable the refactored code paths and add functions to the
  API to acquire an "compilation" context; set an appropriate
  flag on the context to enable XInclude for stylesheets.
  Add functions to run compilations on the basis of such an
  "compilation" context.

I would prefer solution 1) as it also provides for setting
of other options; e.g. if we enable the refactored code
paths, then we will need a "compatibility" mode which will
try to preserve some of the current incorrect behaviour
(e.g. whitespace stripping in the stylesheet).

In case this solution is accepted: can you implement this
please? :-)

An additional issue: what to do with documents acquired via
the document() function? Enable XInclude or not?

Regards,

Kasimier

> -----Original Message-----
> From: Daniel Leidert [mailto:daniel leidert spam gmx net] 
> Sent: Wednesday, August 23, 2006 8:36 PM
> To: The Gnome XSLT library mailing-list
> Cc: Buchcik, Kasimier
> Subject: RE: [xslt] XInclude-processing in XSL stylesheets
> 
> Am Mittwoch, den 23.08.2006, 19:55 +0200 schrieb Buchcik, Kasimier:
> > Hi,
> > 
> > Works for me with the CVS HEAD and the following scenario:
> > 
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> > 
> >   <xsl:template match="/">
> > 	  <xsl:param name="foo">
> >       <xsl:variable name="bar">
> >         <xi:include xmlns:xi="http://www.w3.org/2003/XInclude";
> >                     href="xinclude-inc.txt" parse="text"/>
> >       </xsl:variable>
> >       <xsl:message>XIncluded text: "<xsl:value-of
> > select="$bar"/>"</xsl:message>
> >       <xsl:variable name="norm-bar" select="normalize-space($bar)"/>
> >       <xsl:message>Normalized text: "<xsl:value-of
> > select="$norm-bar"/>"</xsl:message>
> >       <xsl:choose>
> >         <xsl:when test="$norm-bar = 'hello'">success</xsl:when>
> >         <xsl:otherwise>failure</xsl:otherwise>
> >       </xsl:choose>
> >     </xsl:param>
> >     <xsl:value-of select="$foo"/>
> >   </xsl:template>
> > 
> > </xsl:stylesheet>
> > 
> > The file "xinclude-inc.txt" contains only the text "hello".
> > 
> > Result:
> > 
> > XIncluded text: "hello"
> > Normalized text: "hello"
> > <?xml version="1.0"?>
> > success
> 
> Something similar also already worked for me (with Daniel Veillard's
> patch, mentioned in this thread). The "problem": This is not, how
> docbook-xsl inbounds parameters (they are in a separate XSL file
> param.xsl, the is included by docbook.xsl using xsl:include). 
> I attached
> sample files to test the issue (arcticle.001.xml was just 
> taken from the
> testdocs SVN directory of docbook-xsl). With these files you should be
> able to reproduce the problem. The results are:
> 
> $ xsltproc --xinclude xinclude.xsl article.001.xml
> => Read content of xinclude-inc.txt: "failure"
> 
> $ java -cp 
> "/usr/share/java/saxon.jar:/usr/share/java/xercesImpl.jar" \
>     
> -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.j
> axp.DocumentBuilderFactoryImpl \
>     
> -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SA
> XParserFactoryImpl \
>     
> -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apac
> he.xerces.parsers.XIncludeParserConfiguration \
>     com.icl.saxon.StyleSheet article.001.xml xinclude.xsl
> => Read content of xinclude-inc.txt: "success"
> 
> $ java -cp 
> "/usr/share/java/xalan2.jar:/usr/share/java/xercesImpl.jar" \
>     
> -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apac
> he.xerces.parsers.XIncludeParserConfiguration \
>     org.apache.xalan.xslt.Process -in article.001.xml -xsl 
> xinclude.xsl
> => Read content of xinclude-inc.txt: "success"
> 
> > Your file seems to exist, since if it is not found, then
> > we'll get the following error message:
> > 
> > xinclude-1.xsl:8: element include: XInclude error :
> > could not load xinclude-inc.txt, and no fallback was found
> 
> It exists.
> 
> > Very vague question: does your referenced file really contain
> > the values you compare against? (Note that normalize-space()
> > does not change the case of letters)
> 
> Yes, it does :)
> 
> Regards, Daniel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]