xsl-list
[Top] [All Lists]

RE: Attribute value

2005-11-28 04:20:37
Hi All,

I have an xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
                <xsl:output method="html" version="1.0" encoding="ISO8859_1"
indent="yes"/>
                        <xsl:template match="/">
        <html><xsl:text>&#013;</xsl:text>
        <head><xsl:text>&#013;</xsl:text>
<title>INDEX</title>    
        </head>
        <body><ul>
                <xsl:for-each select="//top">
<li>
        <object type="text/sitemap"><xsl:text>&#013;</xsl:text>
                <xsl:apply-templates select="keys/key" />
                </object></li>
                </xsl:for-each>
                </ul>
                        <xsl:text>&#013;&#013;</xsl:text>
                        </body>
        </html>
</xsl:template>

<xsl:template match="keys/key">
        <param name="Keyword" value="{.}"/>
                                <test name="Local">
                        <xsl:attribute name="value">
                                                        <xsl:value-of
select="current()/parent::*/@path"/>
                                </xsl:attribute> 
                </param>
</xsl:template>

Using this xsl I am getting 
        <test name="Keyword" value="{.}"/>

But I can't able to get 
<test name="Local" value=""/>

When looking for keys/key in particular file it should add @path value to
param.


Output as required:

<test name=Name value="fdsfdfdf"/>
<test name="local" value="c:\test\test001\sec1.htm"/>
<test name=Name value=" kjkhkhhj "/>
<test name="local" value="c:\test\test001\sec1.htm"/>

As there are two key element for each i need <test name="Local" value=""/>.

How to do this using xsl.



-----Original Message-----
From: Mukul Gandhi [mailto:gandhi(_dot_)mukul(_at_)gmail(_dot_)com] 
Sent: Saturday, November 26, 2005 10:21 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Attribute value

Hi Shailesh,
  There are well formdness errors in your source XML. In the output
HTML, in the first instance you desire <test name="local" and in the
second instance you desire <test name="NAME". I guess this is a typo,
and you desire <test name="local" in both the cases. I am also curious
that <test is not a HTML tag or this is what you want. Can you clarify
all the points?

Below are the source XML and the stylesheet I think you need

<root>
<file path="c:\test\test001\sec1.htm">
<top>
<p>asafdsf</p>
<keys>
<key>fdsfdfdf</key>
<key>kjkhkhhj</key>
</keys>
</top>
</file>
<file path="c:\test\test001\sec2.htm">
<top>
<p>asafdsf</p>
<keys>
<key>fdsfdfdf</key>
<key>kjkhkhhj</key>
</keys>
</top>
</file>
</root>

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">

<xsl:output method="html" />

<xsl:template match="/root">
   <html>
     <head>
       <title/>
     </head>
     <body>
       <ul>
         <xsl:for-each select="file">
           <li>
             <xsl:for-each select="top/keys/key">
               <test name="Name" value="{.}"/>
             </xsl:for-each>
             <test name="local" value="{(_at_)path}"/>
           </li>
         </xsl:for-each>
       </ul>
     </body>
   </html>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul

On 11/25/04, Shailesh Shinde <shailesh(_at_)quagnito(_dot_)com> wrote:
Hi All,

I have an xml file as:

<file path="c:\test\test001\sec1.htm">
<top>
<p>asafdsf</p>
<keys>
<key>fdsfdfdf</key>
<key>kjkhkhhj</key>
</keys>
<top>
</file>
<file path="c:\test\test001\sec2.htm">
<top>
<p>asafdsf</p>
<keys>
<key>fdsfdfdf</key>
<key>kjkhkhhj</key>
</keys>
<top>
</file>

And so on....

I am trying to get the output as:

<html><body>
<ul><li>
<test name=Name value="fdsfdfdf"/>
<test name=Name value=" kjkhkhhj "/>
<test name="local" value="c:\test\test001\sec1.htm"/>
</li>
<li>
<test name=Name value="fdsfdfdf"/>
<test name=Name value="kjkhkhhj"/>
<test name="NAME" value="c:\test\test001\sec2.htm"/>
</li>
</ul>
</body></html>


When I am searching for key value from particular file the @path value
should come in value="" attribute.


How should i get this?

Thanks,
Shailesh

--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--