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

August 7th, 2006, 09:56 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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"><?xml version="1.0" encoding="UTF-8"?>
<results><result>Test1</result><result>Test2</result></results>
</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
|
|

August 7th, 2006, 12:00 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

August 7th, 2006, 03:01 PM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 8th, 2006, 10:48 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

August 9th, 2006, 10:11 AM
|
|
Registered User
|
|
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 9th, 2006, 03:47 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|
 |