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

Re: Mode in XSLT 3.0

Subject: Re: Mode in XSLT 3.0
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 25 Jul 2017 15:45:25 -0000
Re:  Mode in XSLT 3.0
So I went and pulled the package example out of the spec and got that to
run from the command line.

I can construct (and have attached) a trivial example where there
are block, table, list, and figure elements and equally trivial packages
with block, table, list, and figure modes and template matches.

This is meant to be the simplest possible case that models DITA domains
(or HL7v3 component schemas, or any other lego-block style vocabulary.)

I can write a top-level stylesheet referencing all this and SaxonHE
9.8.0.3 will run it using

java -cp ~/bin/saxon/saxon9he.jar net.sf.saxon.Transform -it
-xsl:mode-eg.xsl -s:simple-eg.xml -o:test-out.xml
-lib:block-pkg.xsl:fig-pkg.xsl:table-pkg.xsl:list-pkg.xsl

If I'm understanding packages correctly, individual packages MUST have
their own unique modes.  Any given xsl:apply-templates instruction can
specify one and only one mode.  So in XSLT 3.0, if I want to have
several packages, one per domain/category/vocabulary-lego-block, and
apply them all in an apply-templates way to the source document, I must:

<xsl:template name="xsl:initial-template">
   <xsl:variable name="mode1">
       <xsl:apply-templates mode="main" />
   </xsl:variable>
   <xsl:variable name="mode2">
       <xsl:apply-templates select="$mode1" mode="block"/>
   </xsl:variable>
   <xsl:variable name="mode3">
       <xsl:apply-templates select="$mode2" mode="figure"/>
   </xsl:variable>
   <xsl:variable name="mode4">
       <xsl:apply-templates select="$mode3" mode="table"/>
   </xsl:variable>
   <xsl:variable name="mode5">
       <xsl:apply-templates select="$mode4" mode="list"/>
   </xsl:variable>
   <xsl:sequence select="$mode5"/>
</xsl:template>

This -- provided all the packaged modes have @on-no-match="shallow-copy"
-- gets the expected result, but I look at it and think that I have to
be doing this wrong.

Is there a better way to approach this?

Thanks!
Graydon

[demime 1.01d removed an attachment of type application/zip]

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.