xsl-list
[Top] [All Lists]

Re: Grouping with keys

2006-02-07 06:11:42
Hi prakash,

thanks for helping, this is a good idea, but in my "big" xslt, i have a
construction, where i need a solution with a key. 

have you/someone an idea, what´s wrong in my key version?


--- Ursprüngliche Nachricht ---
Von: omprakash(_dot_)v(_at_)polaris(_dot_)co(_dot_)in
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: Re: [xsl] Grouping with keys
Datum: Mon, 6 Feb 2006 12:30:52 +0530






Hi,
   See if this is what you want.

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

<xsl:output encoding="ISO-8859-1"/>

 <xsl:template match="sect">
      <sect>
      <title>
      <xsl:for-each select="p[pPr/pStyle/@val='Heading1']">
 <xsl:value-of select="r/t"/>

      </xsl:for-each>
      </title>

      <programlisting>
      <xsl:for-each select="p[pPr/pStyle/@val='Programlisting']">
 <xsl:value-of select="r/t"/>

      </xsl:for-each>
      </programlisting>
      </sect>
</xsl:template>


</xsl:stylesheet>


The result I got was:

<?xml version="1.0" encoding="ISO-8859-1"?>

                         <sect>
                        <title>Erste Ueberschrift</title>

<programlisting>&lt;HTML&gt; &lt;HEAD&gt;</programlisting>
                        </sect>

Hope this helps.

cheers,
prakash




                                                                          
                                                     
                      "Silvia Liberto"                                    
                                                     
                      <SLiberto(_at_)gmx(_dot_)de         To:     
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com                              
           
                      >                        cc:      (bcc:
omprakash.v/Polaris)                                              
                                               Subject: [xsl] Grouping
with keys                                                
                      02/03/2006 09:40                                    
                                                     
                      PM                                                  
                                                     
                      Please respond                                      
                                                     
                      to xsl-list                                         
                                                     
                                                                          
                                                     
                                                                          
                                                     




Hello all,

i have a grouping problem.
I want to group in this example p with val="Heading1" and p with
val="Programlisting".
I have problems with the programlisting, i think my "match" is not
correct.
I´ve tried several things but nothing works, have someone an idea what´s
wrong!?

Thanx
Silvia

here is my code:

xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<wordDocument>
             <body>
                         <sect>
                                     <p>
                                                 <pPr>
                                                             <pStyle
val="Heading1"/>
                                                 </pPr>
                                                 <r>
                                                             <t>Erste
Ueberschrift</t>
                                                 </r>
                                     </p>
                                     <p>
                                                 <pPr>
                                                             <pStyle
val="Programlisting"/>
                                                 </pPr>
                                                 <r>

<t>&lt;HTML&gt;</t>
                                                 </r>
                                     </p>
                                     <p>
                                                 <pPr>
                                                             <pStyle
val="Programlisting"/>
                                                 </pPr>
                                                 <r>

<t> &lt;HEAD&gt;</t>
                                                 </r>
                                     </p>
                         </sect>
             </body>
</wordDocument>


Xslt:

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

<xsl:key name="heading" match="wordDorcument/body/sect/p"
use="generate-id((preceding-sibling::p[pPr/pStyle/@val='Heading1'" />
<xsl:key name="prog" match="pPr/pStyle/@val='Programlisting'"
use="generate-id((preceding-sibling::p[pPr/pStyle/@val='Programlisting'"
/>

 <xsl:template match="p">
 <xsl:choose>
                         <xsl:when test="pPr/pStyle/@val='Heading1'">
                                     <title>
                                                 <xsl:value-of
select="r/t"/>
                                     </title>
                         </xsl:when>
                         <xsl:when
test="pPr/pStyle/@val='Programlisting'">
                         <programlisting>
                                      <xsl:for-each
select="key('prog',generate-id())">
                                                 <xsl:value-of
select="r/t"/>
                                      </xsl:for-each>
                         </programlisting>
                         </xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>





--
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++

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





This e-Mail may contain proprietary and confidential information and is
sent for the intended recipient(s) only.
If by an addressing or transmission error this mail has been misdirected
to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction,
dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its
attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

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


-- 
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++

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