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 August 7th, 2006, 09:56 AM
Registered User
 
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Transformation of XSL text

Hello,
I have a sample XML as shown below

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <env:Body>
        <n1:dataResponse xmlns:n1="http://www.test.com">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;results&gt;&lt;result&gt;Test1&lt;/result&gt;&lt;result&gt;Test2&lt;/result&gt;&lt;/results&gt;
    </n1:dataResponse>
    </env:Body>
</env:Envelope>
While I am transforming the XSL, I would like to display the results as a table of values. However, I am not able to transform the XML inside the dataResponse tag and render it. It merely renders as a text value.
I am looking for information on how to apply transformations on this enclosed value from within an XSL that is parsing the entire document.

Thanks in advance
VS

 
Old August 7th, 2006, 12:00 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This is a poor design of source document. When one XML document contains another XML document, and the inner document has all the angle brackets escaped (or put in CDATA which amounts to the same thing) then you need to parse it twice: after the first parse you can extract the inner document as text, you then need to put it through a parser to turn it into a tree before you can transform it. How you do this depends on your environment - Saxon has a function saxon:parse() which helps a lot.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 7th, 2006, 03:01 PM
Registered User
 
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mike,
Thanks for writing back. This is happening because we have a WebService, which is called by a different WebService and the calling Web Service response returns the called WS response as the value of response element.
I need to read the embedded XML document and apply a transformation on it. However, in the XSL template to parse the response for the calling Web Service, the value is returned with the < and > escaped. Due to these escape values, the variable holding this value cannot be used as a node-set to render the individual nodes inside the XML.

I am wondering if there is a way to un-escape this character values and apply the transformation on this node tree.
Do you think saxon:parse command would do the trick?

Thanks again

 
Old August 8th, 2006, 10:48 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I thought I already answered - you need to pass the text containing the escaped markup to an XML parser to create a node tree before you can transform it.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 9th, 2006, 10:11 AM
Registered User
 
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mike,
Yes you did reply to the question. However, I am encountering an error when I am trying to parse the variable containing this value.

Compile error(s): The first argument to the non-static Java function 'parse' is not a valid object reference. Could not compile stylesheet [transform-1900007]

I am wondering what could be causing this?

Thanks,
SG

 
Old August 9th, 2006, 03:47 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Not sure why you're not binding to the saxon:parse() extension correctly. Check the Saxon namespace, check the Saxon version, try the -TJ option.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl transformation ... rajesh_css XSLT 5 September 30th, 2008 12:37 AM
XSL-Transformation atulshin XSLT 4 September 15th, 2008 06:37 AM
WML and XSL transformation. Feodorov XSLT 2 February 13th, 2008 05:00 PM
XSL transformation problem kawal.singh XSLT 2 December 5th, 2006 05:58 AM
XSL transformation Thodoris XML 0 May 20th, 2004 08:33 AM





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