command-line XML input through a string ?
Added by Anonymous over 17 years ago
Legacy ID: #4187103 Legacy Poster: veronica ced (veronica_ced)
Hi, I'm trying to run a query on an XML file, that I don't want to write to disk. Instead I would like to pass the whole XML string as an argument to Saxon, or alternatively to use the standard input. I know there is a "-s" option on the command-line saxon that enables to query a given file or URL, but that still requires me to write the file to disk. Is what I'm trying to do possible with Saxon? Thanks, Veronica
Replies (4)
Please register to reply
RE: command-line XML input through a string ? - Added by Anonymous over 17 years ago
Legacy ID: #4187387 Legacy Poster: Michael Kay (mhkay)
I would recommend that to do this kind of integration, you should consider using the Java API to run queries rather than using the command line. This opens up a wide variety of possibilities for how the input is passed to Saxon: it could be as a string of lexical XML (wrapped inside a StringReader inside a StreamSource), or as a SAX stream, or a tree in a variety of formats: DOM, JDOM, XOM or Saxon's own TinyTree format. Using the Java API rather than the command line gives a big performance advantage because you aren't loading the Java VM from scratch each time you run a query. However, if you really do want to use the command line, you can use "-s -" to take input from standard input.
RE: command-line XML input through a string ? - Added by Anonymous over 17 years ago
Legacy ID: #4188291 Legacy Poster: veronica ced (veronica_ced)
Hi, thanks for your answer. So far, I've been using Saxon through command-line because the application I develop is written in PHP. Is there a way I could invoke the Java API from PHP? Thanks, Veronica
RE: command-line XML input through a string ? - Added by Anonymous over 17 years ago
Legacy ID: #4188419 Legacy Poster: Michael Kay (mhkay)
There's a bridge available: http://php-java-bridge.sourceforge.net/pjb/ but I've no idea how good it is. The other approach is to run your transformations in a Java servlet and send the requests and responses using HTTP - a little web service. A bit more complex to set up, but likely to give vastly better performance than issuing an exec() on the command line, I would think, especially if you can cache the compiled stylesheets or queries.
RE: command-line XML input through a string ? - Added by Anonymous over 17 years ago
Legacy ID: #4385665 Legacy Poster: holtkamp (holtkamper)
The PHP-Java bridge solution works quite well for this purpose.
Please register to reply