Re: [xsl] Re-insert IDs and RIDs

Subject: Re: [xsl] Re-insert IDs and RIDs
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 20 Oct 2008 08:14:43 -0400
At 2008-10-20 09:31 +0530, J. S. Rawat wrote:
Have anybody any idea about how to re-insert IDs and RIDs as shown in the following example by xslt 2.0.

Not sure what aspect of the problem you are asking about. Below is a solution based on the limited evidence you've given ... I may have made incorrect assumptions regarding some properties of your vocabulary.

It would help next time if you specified what the nature of your question is so that those who try to help know where to advise.

I hope this helps.

. . . . . . . . . Ken

t:\ftemp>type rawat.xml
<p> xxx <anchor rid="a5">key 1</anchor> ... <anchor rid="a8">key 2</anchor> xxx <anchor rid="a5">key 1</anchor> ... <anchor rid="a8">key 2</anchor></p>
<key id="a5">key 1</key>
<key id="a8">key 2</key>

t:\ftemp>xslt2 rawat.xml rawat.xsl con
<?xml version="1.0" encoding="UTF-8"?><doc>
<para> xxx <x rid="x1">key 1</x> ... <x rid="x2">key 2</x> xxx <x rid="x1">key 1</x> ... <x rid="x2">key 2</x></para>
<item id="x1">key 1</item>
<item id="x2">key 2</item>
t:\ftemp>type rawat.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="";

<xsl:key name="ids" match="key" use="@id"/>

<!--map attributes-->
<xsl:template match="@rid | @id">
  <xsl:attribute name="{name(.)}">
    <xsl:for-each select="key('ids',.)">

<!--map elements-->
<xsl:template match="p">
  <para><xsl:apply-templates select="@*|node()"/></para>

<xsl:template match="keys">
  <items><xsl:apply-templates select="@*|node()"/></items>

<xsl:template match="key">
  <item><xsl:apply-templates select="@*|node()"/></item>

<xsl:template match="anchor">
  <x><xsl:apply-templates select="@*|node()"/></x>

<!--identity for all other nodes-->
<xsl:template match="@*|node()">
    <xsl:apply-templates select="@*|node()"/>



Upcoming XSLT/XSL-FO hands-on courses:      Wellington, NZ 2009-01
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video sample lesson:
Video course overview:
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.
Male Cancer Awareness Nov'07
Legal business disclaimers:

Current Thread