[DDI-users] Re: varGrp/var relationships / was: DDI-users Digest, Vol 26, Issue 1

Joachim Wackerow wackerow at zuma-mannheim.de
Mon Oct 9 16:42:36 EDT 2006


Steve,

You have several possibilities to process a list of IDREF's in an 
attribute. This seems to be a frequent question, so here is the choice.


XML document has DTD

If the DDI document has a DTD, the XSLT processor has knowledge about 
the ID's. You can use the XPath function "id". According to the 
documentation: "the result is a node-set containing the elements in the 
same document as the context node that have a unique ID equal to any of 
the tokens in the list". See:
http://www.w3.org/TR/xpath#function-id
This is the easy alternative and preferable, when all DDI documents have 
a DTD and are valid according to this DTD.


General approach for documents without DTD's

If the DDI document has no DTD, the content (space separated string 
values) of a IDREFS attribute must be processed by an own template. An 
recursive approach is one solution, like the template from DDIXSL below. 
The template is calling itself until all ID's are processed. Here it 
generates a list of DocBook links with the ID as target. Adapting this 
template to your needs should do the job.

The attached template is called by (if the context node is a variable):
<xsl:call-template name="IDREFS">
   <xsl:with-param name="IDRefs" select="normalize-space( @var )"/>
</xsl:call-template>


Approach using xsl:key

Using xsl:key to process ID's is also a common approach with documents
without a DTD. See:
http://www.dpawson.co.uk/xsl/sect2/N4576.html


Approach using EXSL

You can use functions of the extended XSL, if the used XSLT processor 
supports this.
See email from Mark Diggory:
http://www.icpsr.umich.edu/pipermail/ddi-users/2004-October/000226.html

Hope this helps, Achim


Steve McRoberts wrote:
> Thanks to everyone that replied. That will be doable although the 
> attribute seems a little unwieldy with several hundred var elements 
> listed in some cases. It does make it impossible to do XPath to process 
> node lists during transformation presentation. I wanted to XPath all var 
> elements that belonged to a specific group/topic. Instead I imagine I'll 
> have to recursively parameterize the attribute string and chop off a var 
> each visit.
> //Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IDREFS.xsl
Type: text/xml
Size: 704 bytes
Desc: not available
Url : http://www.icpsr.umich.edu/pipermail/ddi-users/attachments/20061009/6ab798a1/IDREFS.xml


More information about the DDI-users mailing list