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

Re: writing out of the current boundary of an element

Subject: Re: writing out of the current boundary of an element
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 20 Nov 2006 11:13:12 +0000
Re:  writing out of the current boundary of an element
On 11/19/06, Nima Kaviani <nkaviani@xxxxxx> wrote:
Hi,

I need to write an element outside the boundary of the "current()"
element which is being written to the output file.

for example having the output below written by my XSLT and considering
that I am filling the values inside the inner, I need to write another
element, as a child of <test:Base>, but based on the values I obtain
while I am writing the inner element:

<test:Base>
<test:Rule>
<test:Inner>
  ####
</test:Inner>
</test:Rule>
</test:Base>

so I need the output to be like this:

<test:Base>
<!--------------The new part-------------------->
<test:newlyAdded>
     *********
</test:newlyAdded>

<test:Rule>
<test:Inner>
  ####
</test:Inner>
</test:Rule>
</test:Base>

Add this template to a basic identity transform:


<xsl:template match="test:Base">
 <test:newlyAdded>
     *********
 </test:newlyAdded>
 <xsl:apply-templates/>
</xsl:template>

This will produce exactly what your example result file shows.

If you need the <test:newlyAdded> element to be different depending on
the contents of <test:base>, then you can use predicates, eg:

<xsl:template match="test:Base[test:Rule/test:Inner = 'xyz']">
 <test:newlyAdded>xyz</test:newlyAdded>
 <xsl:apply-templates/>
</xsl:template>

...then add templates for each "rule".

The problem here is your question and examples are pretty
underspecified, eg you say "based on the values I obtain" but don't
show the values or what output should correspond to what value...

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.