How to insert non editable content within XSL ?

I have an XML with references :
<doc>
  <title>Example</title>
  <table number="1.1.1."/>
  <legend>Editable legend for 1.1.1.</legend>
  <table number="2.2.2."/>
  <legend>A legend for 2.2.2.</legend>
</doc>

To present this XML with Xopus, the XSL should insert non editable content, fetched using @number.
For simplicity let’s assume that for number="1.1.1." there is a file named “1.1.1.html"
which contains <table> <tr><td>...</td></tr> </table>
The HTML should be :
 <div>Example</div>
 <table>
  <tr><td>...</td></tr>
 </table>
 <div>Editable legend for 1.1.1.</div>
 
In XSL the obvious way is to use document()
<xsl:template match="table">
    <div>Table <xsl:value-of select="@num"/> fetched :</div>
    <xsl:variable name="path" select="string(concat(@num,'html'))"/>
    <xsl:copy-of select="document($path)"/>
</xsl:template>
This fails in Xopus with :"Failed to compile stylesheet: The document() function in XSLT is only supported in Internet Explorer”

Another option, is to replace document() with <xi:include>
<xsl:template match="table">
    <div>Table <xsl:value-of select="@num"/> fetched :</div>
    <xsl:variable name="path" select="string(concat(@num,'html'))"/>
    <xi:include xmlns:xi="www.w3.org/.../XInclude" href="{$path}"/>
</xsl:template>

This Fails with [HTTP/1.1 400 Error while serializing XML: document %7B$path%7D not found 2 ms]
Obviously href="{$path}" is fetched as %7B$path%7D, by Xopus not replacing the XSL variable

A third option is to use <x:resolveXIncludes/> in Xopus Island
<x:view name="WYSIWYG View">
    <x:transform xsl="0-prepareXIncludes.xsl"/>
    <x:resolveXIncludes/>
    <x:transform xsl="0-test.xsl"/>
</x:view>
With in "0-prepareXIncludes.xsl"
<xsl:template match="table">
  <xsl:variable name="path" select="string(concat(@num,'html'))"/>
  <xi:include xmlns:xi="www.w3.org/.../XInclude" href="{$path}"/>
</xsl:template>

This fails with [HTTP/1.1 400 Error while serializing XML: document /%7B$path%7D not found 22 ms]
Obviously href="{$path}" is fetched as %7B$path%7D, not replacing the XSL variable

The question could have been "how to use XSL variable in <xi:include> ?

Is there a fourth option ?

Rémi

Parents Reply Children
  • I respond to myself.

    XInclude requires:

    - <xi:fallback> inside <xi:include href="{$path}">

    - a <template> in XSL to render table in Xopus in the last transform of the pipeline

    - <x:resolveXIncludes/> in pipeline with an additional xsl "prepareXIncludes.xsl" in which XSL variables are resolved

    - in Xopus Island, 2 transformations chained in succession

    <x:view name="WYSIWYG View">

     <x:transform xsl="prepareXIncludes.xsl"/>

     <x:resolveXIncludes/>

     <x:transform xsl="test.xsl"/>

    </x:view>

    - for eXist users "enable-xinclude=no" in "conf.xml". With the default config eXist replaces <xi:include in the xsl before sending it to the Xopus client.

     

    The fiddle http://xopusfiddle.net/2gqnB/2/ is updated and works except it lacks:

    - <x:transform xsl="prepareXIncludes.xsl"/> in Xopus Island (Fiddle gives no access to start.html

    - prepareXIncludes.xsl which is the second XSL (Fiddle don’t allow to add extra XSL)

     

    Rémi