[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|