[xsl] xslt, document() Q?

Subject: [xsl] xslt, document() Q?
From: Jakub.Valenta@xxxxxxxx
Date: Thu, 18 Oct 2001 01:05:18 +0300
I am new to the XSLT and I am cosidering the XSLT for the solution of one
problem I face to. Thus I would like to ask is the following is possible in
XSLT or not.

I have one input XML file which I have to translate to other XML using
XSLT, at the same time I want to have some external vocabulary XML files,
which would say how to translate some input values to the output values (I
want to have it separate from the XSLT since it will differ from site to
site, while the XSLT itself should stay the same).

In the following I gave an example (at this moment I want to know only if
it is possible and how, typos are not important),

The following is external vocabulary in a file "table123.xml". Each <item>
specifies value input value <input> and related output substitution for it
<output>
...
<table>
   <item>
     <input>code_1</input><output>code_a</output>
   </item>
   <item>
     <input>code_2</input><output>code_b</output>
   </item>
</table>
...
---------------------------
The input XML file has an element <addr> with attribute "use", its value
should be translated according to the file given above and written to the
output as an elemnt or attribute (not important for me at this moment)
?
   <addr use="code_2">
     <str>route 66</str>
     ?
   </addr>
?
--------------------------
XSLT excerpt
<!?just to define the directory where the conversion vocabulary files
reside -->
<xsl:param name="dir" select="tables/">

<!-- here the template should accept two parameters "tableno" specifying
the file with vocabulary (table123.xml in this case) and "v3code" defining
the code to be translated -->
<xsl:template name="translate_v3-v2">
   <xsl:param name="tableno"/>
   <xsl:param name="v3code"/>
   <!-- this should take the right file and find item which has <input>
equal to "v3code" and should return <output> value, IS IT POSSIBLE LIKE
THIS? -->
   <xsl:value-of select="document(concat($dir, 'table', $tableno,
'.xml'))/table/item[input=$v3code]/output/text()"/>
</xsl:template>

?
   <!-- this should just call the template for the <addr> elemnt and pass
the parameters correctly -->
     <xsl:template match="addr">
        <xsl:call-template name="translate_v3-v2">
          <xsl:with-param name="tableno">123"</xsl:with-param>
          <!?how to set the value of this parameter to the value of the
attribute "use"? Is it possible like this? -->
          <xsl:with-param name="v3code" select="@use"/>
        </xsl:call-template>
     </xsl:template>>
?

--------------------------------
any help appreciated,

br,

Jakub V.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread