Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
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 January 23rd, 2008, 12:18 PM
Authorized User
 
Join Date: Jan 2008
Location: Austin, TX, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dved Send a message via Yahoo to dved
Default Converting String into Node-set

Usage in SAXON9

I am wondering if I can directly convert a String into xml Node set and return it. Currently my code gets a node set(doc in java). Java code does what it needs to do and then returns a HTML in a string.

I want to return a Node-set and not a string. Currently I m using :
String S="<tr>"
DocumentBuilderFactory factory= DocumentBuilderFactory.newDocumentBuilder();
DocumentBuilder builder=factory.newDocumentBuilder();
document html=builder.parse(newInputSource(new StringReader(S)));

then create more childs and keep adding to this string.

then return Document;

Is there another cleaner way.

Thanks
__________________
Thanks
Dved
 
Old January 23rd, 2008, 12:23 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Are you asking how to do the same kind of thing, but in XSLT?

There is no way to do this in standard XSLT, but seeing as you are using Saxon then you can use the Saxon extension function, saxon:parse().

http://www.saxonica.com/documentatio...ons/parse.html

/- Sam Judson : Wrox Technical Editor -/
 
Old January 23rd, 2008, 12:23 PM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Your question subject "converting string into node-set" sounds as if you are looking for the saxon:parse extension function: http://www.saxonica.com/documentatio...ons/parse.html

 
Old January 23rd, 2008, 12:40 PM
Authorized User
 
Join Date: Jan 2008
Location: Austin, TX, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dved Send a message via Yahoo to dved
Default

I already have a java function(called in xsl) which returns a string. Now I need to do something (in my java function) so that I convert this string into a document may be and return it to XSL. So XSL reads it as a node set and not as a string.

If I use the method that I said before then I have to go and change each line as I need to append a chile everytime. So I was looking for a kind of type cast mechanism which makes this string into a document or any form that XML understands (like nodeset) but a string.

Note: the problem with string is that it contains < and > symbols and these get interpreted by XSL as &lt and &gt. I dont want it that way.




Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath: set operation with a disjoint node set rich_unger XSLT 7 May 6th, 2008 09:24 AM
converting node to string mister_mister XSLT 2 January 24th, 2008 12:23 PM
Filtering out from a node set anothervbaddict XSLT 1 May 22nd, 2007 08:42 AM
Converting a set of string to its ascii value... rittwick Beginning VB 6 4 April 2nd, 2007 10:46 AM
node-set function Bernardo Pacheco XSLT 2 June 19th, 2006 10:45 AM





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