|
[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
> The is regarding Callstack overflow error.
>
> Dimitrie suggested to implement Divide and Conquer Solution to avoid such
a
> problem.
>
> I saw his example at this site.
> http://www.topxml.com/code/default.asp?p=3&id=v20020107050418
>
>
> How do i write DVC algorithm for the following Call-Template. Here I am
having
> data also in the parameter. And my input file is going to be in GBs and
every
> time the "names" param in the following snippet is going to huge number
atlest
> more than 1000 as there are 10 attributes in each node and there will be
1000
> or more nodes like that.
>
> I am trying to get unique attribute names for say node "SecondNode" which
can
> repeat any number of times.
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








