Re: [xsl] Creating custom IDs using Parent name tree

Subject: Re: [xsl] Creating custom IDs using Parent name tree
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 24 Jul 2007 15:57:51 +0100
> The real problem is creating the ID, accessing that ID (which exists only in 
> the resulting document), and appending the child elements name to it.


one way is just to always pass the current id on as a parameter, so
whenever you currently have

<xsl:apply-templates/>

have

<xsl:apply-templates>
  <xsl:with-param name="id" select="$id"/>
</xsl:param>

if you are just passing through, or

<xsl:apply-templates>
  <xsl:with-param name="id" select="$thisid"/>
</xsl:param>

if you calculated a new id on this template, stored in  a thisid
variable.

Of course this assumes that your apply-template call stack mirrors the
logical hierarchy of your schema, which is the case for simple schemas
but might be hard to achieve if your schema has lots of xsd weirdness
like substitution groups and imports etc. That's a general feature of
processing XSD not specific to the current problem, the XSD files _are_
XML but the important linking structure in the XSD model is sufficiently
different from the natural heirachy you get from the XMl nesting that
often you end up having to write (or find) a schema processsor to input
into something more managable.

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread