xsl-list
[Top] [All Lists]

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

2008-01-03 03:47:56
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[(_at_)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(_at_)edcindia(_dot_)com> 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>