xsl-list
[Top] [All Lists]

Re: Unique IDs?

2005-03-23 03:21:49
That's the correct xml:

<tc id="123">
        <pc>
                <status id="1" name="Status 1"/>
                <status id="2" name="Status 2"/>
                <status id="1" name="Status 1"/>
        </pc>
</tc>
<tc id="124">
        <pc>
                <status id="5" name="Status 5"/>
                <status id="1" name="Status 1"/>
        </pc>
</tc>
<tc id="125">
        <pc>
                <status id="1" name="Status 1"/>
        </pc>
</tc>

Michael Kay wrote:

Your stylesheet is giving you exactly what you asked for: it's outputting
the Status value only if it is the first one with that combination of id's.

To treat the contents of each <pc> as a separate group you will need to
factor the identity (generate-id()) of the pc element into the key value.

Michael Kay
http://www.saxonica.com/ 


-----Original Message-----
From: Sven Waibel [mailto:sven(_dot_)waibel(_at_)imbus(_dot_)de] 
Sent: 23 March 2005 08:38
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Unique IDs?


Good morning!

in my xsl:

<xsl:key name="ids" match="tc/pc/*[(_at_)id]" 
use="concat(../../@id,@id)" />

<xsl:template match="pc">
     <xsl:apply-templates select="*[(_at_)id and generate-id(.)= 
generate-id(key('ids', concat(../../@id,@id)))]" />
</xsl:template>

<xsl:template match="tc/pc/*[(_at_)id]">
 <fo:block><xsl:value-of select="@name" /></fo:block>
</xsl:template>


my xml:

<tc id="123">
     <pc>
             <status id="1" name="Status 1"/>
             <status id="2" name="Status 2"/>
             <status id="1" name="Status 1"/>
     </pc>
     <pc>
             <status id="5" name="Status 5"/>
             <status id="1" name="Status 1"/>
     </pc>
     <pc>
             <status id="1" name="Status 1"/>
     </pc>
</tc>

The current output looks as followed:

"pc1"   Status 1
     Status 2

"pc2" Status 5

"pc3"         


The output should look as followed:

"pc1"   Status 1
     Status 2

"pc2" Status 5
     Status 1

"pc3"         Status 1

Status No. must not exist more than one in one "pc".

What's wrong with my Stylesheet?

Thanks

Best regards
Sven

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




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