Project

Profile

Help

Running Xquery embeded

Added by Anonymous over 14 years ago

Legacy ID: #7794462 Legacy Poster: pvallone (pvallone)

Hi, I found the following example to run an xquery against an input xml file and result to a html file for Saxon 9-2-0-2. This example uses a new method called newStaticQueryContext(), which is not used in Saxon 9-1-0-7. Is there a similiar example for 9-1-0-7? public static void exampleToHTMLFile() throws XPathException, IOException { final Configuration config = new Configuration(); final StaticQueryContext sqc = config.newStaticQueryContext(); final XQueryExpression exp = sqc.compileQuery(new FileReader("query/books-to-html.xq")); final DynamicQueryContext dynamicContext = new DynamicQueryContext(config); dynamicContext.setContextItem(config.buildDocument(new StreamSource("data/books.xml"))); final Properties props = new Properties(); props.setProperty(OutputKeys.METHOD, "html"); props.setProperty(OutputKeys.DOCTYPE_PUBLIC, "-//W3C//DTD HTML 4.01 Transitional//EN"); exp.run(dynamicContext, new StreamResult(new File("booklist.html")), props); } Thanks, Phil


Replies (3)

Please register to reply

RE: Running Xquery embeded - Added by Anonymous over 14 years ago

Legacy ID: #7794489 Legacy Poster: pvallone (pvallone)

Never-mine - Found it -

RE: Running Xquery embeded - Added by Anonymous over 14 years ago

Legacy ID: #7794553 Legacy Poster: Michael Kay (mhkay)

In Saxon 9.1 you can use the constructor new StaticQueryContext(config). I introduced the factory method in 9.2 because it can now return a subclass of StaticQueryContext with extra functionality in the PE/EE products.

RE: Running Xquery embeded - Added by Anonymous over 14 years ago

Legacy ID: #7794590 Legacy Poster: pvallone (pvallone)

Thanks MIchael. You're always a great help.

    (1-3/3)

    Please register to reply