This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: convert string to xml record
- From: Ming <myu at lanl dot gov>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 16 May 2002 11:02:55 -0600
- Subject: Re: [xsl] convert string to xml record
- References: <000001c1fc6c$b4b76570$0400a8c0@fcmobilexpp>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi,
First, thank all who helped me on this topic. After reading your
suggestions and search the archive and the web, I finally find the solution
although may not be the best one. Just to share with everyone. The original
codes I found is on this site:
http://download-west.oracle.com/otndoc/oracle9i/901_doc/appdev.901/a88894/adx04xsl.htm
This is what I did. I downloaded the xml parser package from oracle site
and use their DOMParser package and here is my java method used to parse
the string:
import java.util.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import java.io.StringReader;
import oracle.xml.parser.v2.*;
public static NodeList parseXml (String s) {
DOMParser d = new DOMParser();
try {
d.parse( new StringReader(s) );
return ((XMLDocument)d.getDocument()).selectNodes("/");
} catch (Exception e) {
return (new XMLDocument()).getChildNodes();
}
}
Hope this will help someone.
Ming
Stuart Celarier wrote:
> The only XSLT 1.0 way that I know how to do that is with the document()
> function, assuming that the string can be addressed with a URI. That
> means that string can be served up as a URL from a web server, or the
> string can be in a file on the file system, or even a fragment within a
> file.
>
> Individual XSLT vendors may implement extension functions if you can tie
> your application to a specific XSLT processor. I can't make specific
> recommendations but look for such parsing functions in Saxon, Xalan,
> etc. I am not aware of any such extension functions for MSXML or MS
> .NET.
>
> Cheers,
> Stuart
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list