[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Replacing values in xml files.....

Subject: Re: Replacing values in xml files.....
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Thu, 3 Jan 2008 16:17:23 +0530
Re:  Replacing values in xml files.....
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.