[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: priority of key patterns

Subject: Re: priority of key patterns
From: Ihe Onwuka <ihe.onwuka@xxxxxxxxx>
Date: Wed, 14 Nov 2012 11:09:32 +0000
Re:  priority of key patterns
On Wed, Nov 14, 2012 at 10:59 AM, Ihe Onwuka <ihe.onwuka@xxxxxxxxx> wrote:
> On Wed, Nov 14, 2012 at 10:44 AM, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote:
>>>> <xsl:template match="EmployeeCategory | PersonName | FormerlyKnown">
>>>>   <Name>
>>>>
>>>
>>> I cut the examples off with .... too early. Here are a few more
>>> illustrating the more general case for which that solution will not
>>> work.
>>>
>>>  <ren:element from="Directors" to="Names"/>
>>>  <ren:element from="ParentCompany" to="Names"/>
>>>  <ren:element from="LegalStatusAdditional" to="AdditionalInfo"/>
>>>  <ren:element from="EmployeeChanges" to="Changes"/>
>>
>> ...just add more templates!?!
>>
>
> I think it is better to achieve it by adding data (which is what that
> variable is).

and  it is extensible to  attributes at the cost of 1 very similar
template rule.

<xsl:variable name="renames">
   <ren:element from="person" to="individual"/>
   <ren:attribute from="firstname" to="christianname"/>
   <ren:attribute from="lastname" to="surname"/>
</xsl:variable>

<xsl:template match="*[key('mapNames',name(),$renames)]">
    <xsl:element name="{key('mapNames',name(),$renames)[1]}">
        <xsl:apply-templates select="node()|@*/>
    </xsl:element>
</xsl:template>

<xsl:template match="@*[key('mapNames',name(),$renames)]">
    <xsl:attribute name="{key('mapNames',name(),$renames)[1]}">
        <xsl:apply-templates select="node()|@*/>
    </xsl:attribute>
</xsl:template>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.