Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2009, 11:38 AM
Authorized User
 
Join Date: Nov 2009
Posts: 11
Thanks: 6
Thanked 0 Times in 0 Posts
Default Need to redirect XML outputted by style sheet back into same style sheet

Hello,

The style sheet is changing an attribute from the original XML. It is also creating a report that calls that attribute and printing it out in a .csv. The problem is the report calls the attribute from the original XML when it needs to call the changed attribute.

Can the output XML be redirected back into the style sheet and processed for the .csv report?
 
Old November 6th, 2009, 11:42 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

With XSLT 2.0 you can certainly easily create a temporary result and process it further. You only need to be careful that you don't end up with infinite processing, for instance by using different modes for each processing step.
With XSLT 1.0 you would need to use an extension function like exsl:node-set to convert a temporary result in the form of a result tree fragment into a node-set to process it further. Again using modes to distinguish between processing steps makes sense.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old November 6th, 2009, 02:38 PM
Authorized User
 
Join Date: Nov 2009
Posts: 11
Thanks: 6
Thanked 0 Times in 0 Posts
Default

"With XSLT 2.0 you can certainly easily create a temporary result and process it further."

Sorry, but I am too new to xslt to know how to do that. The document function was recommended to me, and I'll look into that.
 
Old November 6th, 2009, 02:44 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

A temporary result is simply a result stored in a variable:
Code:
<xsl:template match="/">
  <xsl:variable name="v1">
     <xsl:apply-templates/>
  </xsl:variable>
  <xsl:apply-templates select="$v1/*" mode="m1"/>
</xsl:template>
<!-- now write templates for the default mode that perform the first step
      and templates for the mode m1 that perform the second step e.g. -->
<xsl:template match="foo">
   <xsl:copy>
     <xsl:attribute name="bar">value</xsl:attribute>
   </xsl:copy>
</xsl:template>

<xsl:template match="foo" mode="m1">
  <xsl:value-of select="@bar"/>
</xsl:template>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
Kenneth.Dougherty (November 9th, 2009)
 
Old November 9th, 2009, 04:29 PM
Authorized User
 
Join Date: Nov 2009
Posts: 11
Thanks: 6
Thanked 0 Times in 0 Posts
Default thanks for the help

Thanks for the advice.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the style sheet of the Master Page dotnetDeveloper BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 August 4th, 2008 09:56 AM
Chapter 2 -- Style Sheet problem. Doug Happ BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 4 January 10th, 2008 01:14 PM
cascading style sheet problem nikotromus ASP.NET 2.0 Professional 0 March 24th, 2006 07:49 PM
need xsl style sheet help please!(im a begginer) klipss XSLT 2 July 25th, 2005 02:10 PM
Setting the Style Sheet class jacob ASP.NET 1.0 and 1.1 Basics 4 August 20th, 2003 01:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.