 |
| 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
|
|
|
|

March 16th, 2011, 01:56 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Your original post contains a sample of XML called "desired output". This doesn't contain an <outputfile> element, so we're not sure where that came from, nor how you want it to be output.
Try restating your requirements.
|
|

March 16th, 2011, 02:02 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Use the two templates Michael Kay suggested, then to output the "outputfile" element as the first child element of the root element add a template
Code:
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<outputfile><xsl:value-of select="$vLeague_Name"/>_CLIENT_SAMPLE.XML</outputfile>
</xsl:copy>
</xsl:template>
If you want to output the "outputfile" element before the root element then you need
Code:
<xsl:template match="/">
<outputfile><xsl:value-of select="$vLeague_Name"/>_CLIENT_SAMPLE.XML</outputfile>
<xsl:apply-templates/>
</xsl:template>
instead, but take notice that that way you don't get a well-formed XML result document as you can't have two root elements.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|

March 16th, 2011, 02:04 PM
|
|
Authorized User
|
|
Join Date: Sep 2008
Posts: 37
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Sam,
I've edited my XSL code (posted earlier) to reflect the names of the XML that i posted in my original post.
In regards the outputfile element, that's something used by the XT processor to rename the new file.
|
|

March 16th, 2011, 02:16 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Quote:
Originally Posted by vb89
|
I wouldn't use XT, if you use Java then use a conforming implementation like Saxon 6.5.5 for XSLT 1.0 or like Saxon 9 for XSLT 2.0. If you look at the document you linked to it lists some limitations and one of them is "The node() node-test does not work in match patterns" so you simply run into that problem because you use some beta release of an old software.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|

March 16th, 2011, 02:20 PM
|
|
Authorized User
|
|
Join Date: Sep 2008
Posts: 37
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Thanks Martin.
Unfortunately, this is what we use in our production environment -- dumb, i know. Is there a work around that you can think of?
|
|

March 16th, 2011, 02:58 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
If you know that something is dumb then stop doing it.
Building a production system on xt is not just dumb, its insane. The product was never finished, and development stopped over 10 years ago, and there are excellent alternatives.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

March 16th, 2011, 03:08 PM
|
|
Authorized User
|
|
Join Date: Sep 2008
Posts: 37
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Michael, I understand where you're coming from -- for the record we're also using NXSLT (not sure if that helps). However, for the project at hand these are the circumstances that I'm forced to deal with, so I have to adjust to them and work with what I got. If you have any thoughts on a work around, I would appreciate it, if not, I'll have to just continue searching.
|
|

March 16th, 2011, 03:26 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
If you can't do match="node()" then you have to spell out the different node types i.e.
Code:
<xsl:template match="@* | text() | comment() | processing-instruction()">
<xsl:copy/>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
then you need to add other templates below and perhaps use priority to make sure they have higher priority than match="*".
But I would also strongly suggest to change the system to use a conforming XSLT processor and not to rely on workarounds to adapt to some old software.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|
 |