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

Re: output node with subnodes "as-is"

  • To: xml-dev@l...
  • Subject: Re: output node with subnodes "as-is"
  • From: richard@i... (Richard Tobin)
  • Date: Fri, 3 Dec 2004 13:09:45 +0000 (GMT)
  • Cc:
  • In-reply-to: <yg48y8f1xz7.fsf@p...>
  • Organization: HCRC, University of Edinburgh
  • References: <17ee29ab.0412030020.34bb97be@p...>

xsl node sub nodes
>A more usual case is where you want templates
>that do an identity transform but then have higher priority templates
>for certain special attributes that do something other than copy.

I wish XSLT had provided the identity transform as the default
template instead of the markup-stripping ones.

We find this case so common that I have recently written a program
that takes a single template on the command line and inserts it
into a stylesheet with a low-priority identity template:

  lxreplace -q match-expr -t template-body

To make it even simpler for the simple cases, the stylesheet defines
some entities:

 <!ENTITY this
          "<xsl:copy><xsl:apply-templates select='@*|node()'/></xsl:copy>">
 <!ENTITY attrs "<xsl:apply-templates select='@*'/>">
 <!ENTITY children "<xsl:apply-templates select='node()'/>">
 <!ENTITY text "<xsl:value-of select='.'/>">

Simple examples are wrapping elements:

  lxreplace -q 'foo[@bar="unknown"]' -t '<bogus>&this;</bogus>'

renaming elements:

  lxreplace -q 'foo' -t '<bar>&attrs;&children;</bar>'

and moving the text content of an element into an attribute:

  lxreplace -q 'foo' -t '<foo value="{.}"/>'

-- Richard

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.