|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to implement Divide and Conquer Algo on this t
Hi,
Thanks a lot for showing me efficient way of finding unique attribute names
for the attributes.
Since the algorithm which i used is at many places throughtout my solution.
And further processing was based on the output of that template i.e. unique
names seperated with delimiter like this.
Applying the method shown below how do i get the unique names in a variable
like
"a`b`c`m`X`Y`Z"
Actually i was getting output like this and I was doing further processing
based on the output in the form like above.
So could you please tell me how do i get that in the variable and store it as
shown above.
Thanks once again for your help.
Eagerly waiting for your reply.
Regards
Dipesh
>Do not try to use such kind of algorithm for obtaining unique attribute
names because it is inefficient.
>Read about grouping methods here:
>http://www.topxml.com/code/default.asp?p=3&id=v20010129150851
>and here:
>http://jenitennison.com/xslt/grouping/index.html
>Here's an example how to use the Muenchian method for grouping in order to
obtain the unique attributes' names:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:key name="kattNames"
match="firstNode/secondNode/@*" use="name()"/>
<xsl:template match="/">
<xsl:for-each
select="*/*/*/@*[generate-id()
=
generate-id(key('kattNames', name())[1])
]">
<xsl:value-of select="concat(name(), '
')"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the source.xml below:
<root>
<firstNode>
<secondNode a="x" b="y" c ="z"/>
<secondNode a="x" m="y" c ="z"/>
</firstNode>
<firstNode>
<secondNode a="x" X="y" c ="z"/>
<secondNode a="x" m="y" c ="z"/>
</firstNode>
<firstNode>
<secondNode Y="x" b="y" c ="z"/>
<secondNode a="x" m="y" Z ="z"/>
</firstNode>
</root>
the correct result is produced:
a
b
c
m
X
Y
Z
Hope this helped.
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








