@CL wrote:
> I had a xml file like:
> <Details>
> <names>
> <name/>
> <name/>
> ......or more <name/>
> </names>
>
> <orders>
> <order/>
> <order/>
> .....or more <order/>
> </orders/>
That's, uh, not particularly well-formed.
> ....or more element
> </Details>
> the num of details may be as large as 2000,
> first get the nums and simply selected use the [index],
Er, what? Do you mean you need to group name, order etc.
elements depending on their position?
> <xsl:template match="/">
> <Details>
> <detail>
> <name>
> <xsl:value-of
> select="/Details/names/name[1]"/>
> </name>
> <order>
> <xsl:value-of
> select="/Details/orders/order[1]"/>
> </order>
> ....more elements
> </detail>
> ....more detail with the index
> </Details>
> </xsl:template >
You're kidding, aren't you? You wrote that 2000 times or
so? Don't mention this to your team leader, but if *I* were
your team leader, they'd never find your body. What's the
point of using XSLT if you're not actually using it?
> when the num is lagrer than a num ,maybe 30,the JAXP
> would throw the
> javax.xml.transform.TransformerConfigurationExcept ion:
> can't load translet class "GregorSamsa"
Probably something's wrong with your transformation, but
you'd better ask that question on a Java newsgroup.
> I had tried to use the for-each loop
for-each is not a loop.
> and template loop,
Do you mean recursive templates? I would expect your
processor to die horribly trying to cope up with 2000-deep
recursion, unless it happens to be capable of optimizing
tail recursion, and unless your transformation happens to
be tail-recursive.
> but there is always with the syntax error,
I think something's 'there is always with the syntax error'
in this sentence.
> and can you help me£¿
<xsl:stylesheet version="1.0"
xmlns

sl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/Details">
<xsl:copy>
<xsl:apply-templates select="*[1]/*" mode="Detail"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*" mode="Detail">
<xsl:variable name="position" select="position()"/>
<Detail>
<xsl:apply-templates
select="../../*/*[position()=$position]"
mode="copy"/>
</Detail>
</xsl:template>
<xsl:template match="*" mode="copy">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
--
Pavel Lepin