RE: [xsl] How to filter element values...

Subject: RE: [xsl] How to filter element values...
From: cknell@xxxxxxxxxx
Date: Fri, 06 Feb 2004 16:04:58 -0500
Search the list archives for "default template".
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Kotes Mogili <Kotes.Mogili@xxxxxxxxxxxxxxxxx>
Sent:     Fri, 6 Feb 2004 15:24:44 -0500
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  [xsl] How to filter element values...

Hi,

I am using XSL to generate another XSL file from an XML file. I am interested in only Element names and attributes but not it's values. for the following XML 


<SiebelMessage>
<Global param="A" name="Y">aaaaa</Global>
<Global type="if" name="A" select="abcd">bbbb</Global>
<Global type="when" name="Y" select="ccc" otherwise="bbbbb">ccccc</Global>

<EVENT spec="IDL:sciOmSiebelEvents/RouterToOmServer:1.0#OrderCopyEvent\">
 ddddd
</EVENT>
</SiebelMessage>

I am getting the output as 

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
    <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:preserve-space elements=""/>
    <xsl:strip-space elements="*"/>
    <xsl:param name="A"/>

 aaaaa 

<xsl:variable name="A">
        <xsl:value-of select="abcd"/>
    </xsl:variable>

 bbbb 

<xsl:variable name="Y">
        <xsl:choose>
            <xsl:when test=" ">
                <xsl:value-of select=" ccc"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select=" bbbbb"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

 ccccc ddddd 

<xsl:template match="*"/>
    <xsl:template match="SiebelMessage"/>
    <!-- End of SiebelMessage -->
</xsl:stylesheet>


I am not sure why the element values are coming when i am not refering it them. Any suggestions are greatly appreciated..


Thanks

kotes


<!-- *******************  XSL file  ********************** -->

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method="text"/>
<xsl:strip-space elements="*" />   
<xsl:template match="/">
        <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
        <xsl:output method="xml"  encoding="UTF-8" indent="yes"/>
        <xsl:preserve-space elements=""/>
        <xsl:strip-space elements="*"/>
        <xsl:apply-templates select="*[Global]" mode="g"/>
        <xsl:template match="*">
        </xsl:template>
        <xsl:template match="SiebelMessage">
     <!--  <xsl:apply-templates select="SiebelMessage"/>  -->
        <!-- &lt;/xsl:element &gt;-->
        </xsl:template > <!-- End of SiebelMessage -->
     <!--    <xsl:apply-templates select="*" mode="t" />  -->
        </xsl:stylesheet>
 </xsl:template>

<xsl:template match="SiebelMessage">
         <xsl:apply-templates select="EVENT"/>
</xsl:template>

<xsl:template match="EVENT">
                 <xsl:element name="<xsl:value-of select="name()"/>">
                 <xsl:attribute name="spec"><xsl:value-of select="@spec"/></xsl:attribute>
                 <xsl:apply-templates/>
                 </xsl:element >
</xsl:template>

<xsl:template match="Global"  mode="g">
   <xsl:if test="@type='if'">
              <xsl:variable name="<xsl:value-of select="@name"/>">
                <xsl:if test="@select"> <xsl:value-of select="<xsl:value-of select="@select"/>"/></xsl:if>
                <xsl:if test="@hardcode"><xsl:text><xsl:value-of select="@hardcode"/></xsl:text></xsl:if>
              </xsl:variable>
     </xsl:if>
     <xsl:if test="@param">
               <xsl:param name="<xsl:value-of select="@param"/>"/>         
     </xsl:if>
            <xsl:if test="@type='when' ">
                <xsl:variable name="<xsl:value-of select="@name"/>">
                <xsl:choose>
                <xsl:when test=" <xsl:value-of select="@gtest"></xsl:value-of>">
                    <xsl:if test="@select"><xsl:value-of select=" <xsl:value-of select="@select"/>"/></xsl:if>
                    <xsl:if test="@sHardcode"><xsl:text><xsl:value-of select="@sHardcode"/></xsl:text></xsl:if>
                 </xsl:when >
                 <xsl:otherwise>
                     <xsl:if test="@otherwise"><xsl:value-of select=" <xsl:value-of select="@otherwise"/>"/></xsl:if>
                     <xsl:if test="@oHardcode"><xsl:text><xsl:value-of select="@oHardcode"/></xsl:text></xsl:if>
                 </xsl:otherwise>
                 </xsl:choose>
                 </xsl:variable>
     </xsl:if>
     <xsl:apply-templates mode="g"/>
</xsl:template>

 </xsl:stylesheet>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread