Xproc: how to use a variable in an href

399 Views Asked by At

I have a variable that holds the name of the stylesheet to apply next.

This does not work:

<p:variable name="filename" select="'/home/stylesheets/indent.xsl'"/>

<p:xslt>
   <p:input port="stylesheet">
       <p:document href="{$filename}"/>
   </p:input>
</p:xslt>

I think I have to do somekind of URI or IRI function on $filename, but I have not been able to figure it out.

UPDATE: I went to the link that grtjn provided and lifted the <p:declare-step type="ut:xslt" name="current"> wrapper.

Now applying the href from variable is very easy:

<ut:xslt>
    <p:with-option name="href" select="$filename" />
</ut:xslt>
1

There are 1 best solutions below

1
On BEST ANSWER

IMO it is not possible use variable in href attribute. I solved it using <p:load> step like

<p:load name="xslt_from_variable">
  <p:with-option name="href" select="$filename" /> 
</p:load>

In <p:xslt> I bind it to "xslt_from_variable" result port, like

<p:xslt name="xslt_step">
    <p:input port="source">
        <p:pipe step="xslt_from_variable" port="result" /> 
    </p:input>
    ...
</p:xslt>

I hope this attempt will work for you as well as for me.