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

Re: Why can a template rule match on a child of multip

Subject: Re: Why can a template rule match on a child of multiple elements but cannot match on multiple children of an element?
From: "Norm Tovey-Walsh ndw@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 19 May 2022 13:29:23 -0000
Re:  Why can a template rule match on a child of multip
> Why can I have a template rule like this:
>
> <xsl:template
match="(sidRunwayTransition|sidCommonRoute|sidEnrouteTransition)/supplemental
Data">
>
> But I cannot have a template rule like this:
>
> <xsl:template
> match="sid/(sidRunwayTransition|sidCommonRoute|sidEnrouteTransition)">

What is the context in which you find you canbt?

Herebs a document:

<root>
  <branch>
    <A/>
    <A/>
    <B/>
    <B/>
    <C/>
    <C/>
  </branch>
  <alternate>
    <A/>
    <A/>
    <B/>
    <B/>
    <C/>
    <C/>
  </alternate>
</root>

Herebs a stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                exclude-result-prefixes="xs"
                version="3.0">

<xsl:output method="xml" encoding="utf-8" indent="no"/>

<xsl:mode on-no-match="shallow-copy"/>

<xsl:template match="/">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="(branch|alternate)/A">
  <xsl:copy>
    <m1/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

<xsl:template match="branch/(B|C)">
  <xsl:copy>
    <m2/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

And herebs what I get if I apply one to the other:

<?xml version="1.0" encoding="utf-8"?><root>
  <branch>
    <A><m1/></A>
    <A><m1/></A>
    <B><m2/></B>
    <B><m2/></B>
    <C><m2/></C>
    <C><m2/></C>
  </branch>
  <alternate>
    <A><m1/></A>
    <A><m1/></A>
    <B/>
    <B/>
    <C/>
    <C/>
  </alternate>
</root>

                                        Be seeing you,
                                          norm

--
Norman Tovey-Walsh <ndw@xxxxxxxxxx>
https://nwalsh.com/

> There comes a time when a man must take himself, for better or worse,
> as his portion.--Ralph Waldo Emerson

[demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]

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.