Re: [xsl] printing text output excluding some nodes

Subject: Re: [xsl] printing text output excluding some nodes
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Tue, 12 Apr 2005 08:29:55 -0700 (PDT)
Sorry, your problem description is not quite clear to
me! But making a best guess, I could think of this
XSL.. 

<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
 
<xsl:output method="text" /> 
 
<xsl:template match="/">
  <xsl:for-each select="//Data">
    <xsl:if test="not(preceding-sibling::Control[@id =
'a' or @id = 'x'])">
      <xsl:value-of select="." /><xsl:text>
</xsl:text>
    </xsl:if>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul

--- swetha d <swethaxml@xxxxxxxxx> wrote:
> Hi everybody,
>     I am new to xsl.So,please I need some help for 
> writing my xsl style sheet. which is similar to the
> following,
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <?xml-stylesheet href="ss.xsl" type="text/xsl"?>
> <Document>
>   <Group>
>         <Control id="x"/>
>          <Control id="y"/>
>          <Data>follow</Data>
>   </Group>
>    <Group>
>     <Control id="a"/>
>     <Control id="b"/>
>       <Data>hai</Data>
>   </Group>
>   <Group>
>        <Control id="c"/>
>          <Group>
>                <Control id="a"/>
>                <Control id="d"/>
>                 <Data>hello</Data>
>          </Group>
>          <Data>good</Data>
>   </Group>
> <Group>
>          <Control id="e"/>
>            <Data>morning</Data>
>   </Group> 
>   </Document>
> I want my output to contain all the data in xml
> after
> the group having control id as 'x'except the data
> from
> groups having control id'a'(data from the group
> having
> control id 'x' should not be included)
> That means from above xml,I want output as
> good morning
> 
> and my  xslt is like
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="1.0">
>     <xsl:output method="text"  />
>         
>     <xsl:template match="Document">
>              <xsl:for-each select="//Group">
>                       <xsl:if test="Control/@id
> ='x'">
>                            <xsl:for-each
> select="following::*">
>                                <xsl:if
> test="Control/@id !='a'">
>                                 
> <xsl:apply-templates
> />
>                                 </xsl:if>
>                             </xsl:for-each>
>                       </xsl:if>
>             </xsl:for-each>
>    
>     </xsl:template>     
>     
>     </xsl:stylesheet>
> It is giving output as follows
>  hai hello good hello morning
> 
> In xsl,instead of <xsl:if test="Control/@id
> !='a'">,if
> i write <xsl:if test="Control/@id ='a'"> then it is
> printing as  
> hai hello 
> same as what we expect.But when i write <xsl:if
> test="Control/@id !='a'"> why it is printing data 
> hai& hello also?What should i do for printing only
> good morning?
> Thanks,
> Swetha
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
> 
> 


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

Current Thread