[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using the document function with external document

Subject: Re: Using the document function with external documents stored in a database
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Mon, 22 Mar 2004 05:49:19 -0800
dom document function
Bjvrn Boxstart wrote:

Hello all,

I need to perform an XSL-T transformation from Java with Xalan. The challenge is that there are two XML documents involved and that both XML documents are stored in a mysql database. One of the XML documents is the main documents (in the original language). The other document contains a translated version of the source document.

I would like to output a combination of both documents in HTML by using an XSL-T transformation. However I don't want to store the secondary document on the file system of the server before execution of the transformation.

I have two questions:
1. Is it possible to let the document function use a DOM object stored in memory, or an XML document stored in a database?

yes, but you do not need to create a DOM. The best/easiest way would be to use document():


<xsl:apply-templates
  select="document($dbIdentifier)"/>


You need to create (implement) a custom URIResolver like:


public Source resolve(String href, String base) {
  String xmlFromDb = someObj.getXml(href);
  if (xmlFromDb == null) {
    xmlFromDb = "<not-found/>";
  }
  Source source = new StreamSource(new StringReader(xmlFromDb));
/* or
  Source source = new StreamSource(someObj.getXmlAsInputStream(href));
or however...
*/
  return source;
}

best,
-Rob


2. If not... Is it possible to pass a DOM object as a parameter to an XSL-T transformation?

Thanks in advance for your reaction!

Bjvrn

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.