Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Replacing values in xml files.....

From: "Mukul Gandhi" <gandhi.mukul@--------->
To:
Date: 1/3/2008 10:48:00 AM
I would not like to correct the low level details of your code. I want
you to think about that ...

But I would be happy to share know how about the 'document' function
and it's usage.

Please find below a small program illustrating the same.

Let the following XML document be named, delta.xml:

<chapter>
  <p id="p1">text</p>
</chapter>

The following stylesheet is applied to the other (the big one) XML document:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
    <xsl:output method="html"/>
	
    <xsl:variable name="delta" select="document('delta.xml')"/>
	
    <xsl:template match="/">
       <html>
          <head>
             <title/>
          </head>
          <body>
          <table>
             <xsl:for-each select="//edition">
                <xsl:variable name="x" select="." />
	   <tr>
	     <td>
                        <xsl:value-of select="@language" />
                     </td>
	     <td>
	        <xsl:choose>
	           <xsl:when test="$x = $delta/chapter/p/@id">
	              <xsl:value-of select="$delta/chapter/p[@id = $x]" />
	           </xsl:when>
	           <xsl:otherwise>
	              <xsl:value-of select="$x" />
	           </xsl:otherwise>						        </xsl:choose>
	      </td>
	</tr>
              </xsl:for-each>
           </table>
         </body>
      </html>
    </xsl:template>
	
</xsl:stylesheet>

Please run this stylesheet with a XSLT processor, and you can see the output.

PS: The 'document' function can get a reference to an external XML
document (other than the primary one, which is supplied to the
transformation process). You can refer any number of external XML
documents, and store each one in a variable in the stylesheet.


On Jan 2, 2008 4:39 PM, Mujahid - E - Azam <mujahidazam@xxxxxxxxxxxx> wrote:
> Can you please help me with the syntax...
> Also can you please go through the xsl at the bottom and let me know if I am
> going in the right direction....
>
> Thanks & Regards,
>
> Mujahid E Azam



-- 
Regards,
Mukul Gandhi


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent