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

Re: Matching a bundle of elements

Subject: Re: Matching a bundle of elements
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 20 Jul 2011 10:59:01 +0100
Re:  Matching a bundle of elements
On 20/07/2011 10:19, Emma Burrows wrote:
I am converting a large body of legacy XML documents to a DITA-based format using Oxygen 12. One of the problems with the document I'm currently working on is that about 15 different element names in the source will be turned into<topic> elements. I'm finding that I'm having to repeat those 15 elements in various templates in order to create the document maps, normalise cross references, etc. This makes the code difficult to read and is also prone to error if I accidentally miss off one of the elements in a given location.

Is there any way in XSLT 2.0 that I can define the source elements as a group and then refer to that in templates, for-each loops and so on? Or are there any extension functions out there that might help?

Thanks!


If there's a schema, and if you're lucky, the elements will be defined as members of a substitution group, so you can refer to them collectively as schema-element(G) where G is the name of the substitution group head. Alternatively, you might find they are all defined with type T, so you can refer to them as element(*, T).

Without schema support, the only thing that comes to mind is to write a function

<xsl:function name="f:is-topic" as="xs:boolean">
<xsl:param name="e" as="element()"/>
<xsl:sequence select="exists($e[self::A or self::B or self::C....])"/>
</xsl:function>

and use this for example as match="*[f:is-topic(.)]"

Michael Kay
Saxonica

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.