Search multiple xml documents from one xslt

I am trying to do this and cant get it to work. Can someone take a look and see if I'm missing something obvious.

I am referencing an additional document like this in test.xsl.

<xsl:value-of select="document('/customercare/library/test/test1.xml')/resources/resource/name" />

      

This is xml test1.xml.

<resources>
    <resource>  
        <name>configuration</name>
    </resource> 
</resources>

      

This is a snippet call in my asp page index.aspx.

<%
            Dim mm_xsl As MM.XSLTransform = new MM.XSLTransform()
            mm_xsl.setXML(Server.MapPath("/customercare/library/test/test2.xml"))
            mm_xsl.setXSL(Server.MapPath("/customercare/library/test/test.xsl"))            
            Response.write(mm_xsl.Transform())
        %>

      

I am in the process of architecting a site that will have several hundred products. I would like to have one xml document that contains high level data like name and image path for each product that can be fetched externally, this will have a unique schema. Then add another XML document with a unique schema that contains department-specific elements such as support, which will contain document paths, phone numbers, etc.

My question is, how can I fix both xml documents from one xslt?

thank

+2


source to share


3 answers


Take a look at the document () function .



This article provides an overview of its use.

+3


source


When I use XML documents the way you describe (like lookup tables to be referenced during transformation), I usually load them into variables at the top of my transformation:

<xsl:stylesheet...>
   <xsl:variable name='resources' select=document('resources.xml')/>
   <xsl:variable name='products' select="$resources/resources/products/product"/>

      



Then I can search for information from these variables wherever needed, for example:

<xsl:template match='product'>
   <tr>
      <td>
         <xsl:value-of select='@id'/>
      </td>
      <td>
         <xsl:value-of select='@description'/>
      <td>
      <td>
         <img src='{$products[@id=current()/@id]/image}'/>
      </td>
  </tr>
<xsl:template>

      

+1


source


You can of course use the xsl: document () function twice in your stylesheet. But why do you want it so? There seems to be no obvious reason for this.

Other parameters are the fn: doc () XPath function or the xsl: document element.

0


source







All Articles