RE: [xsl] Need Attributes From A InputStream

Subject: RE: [xsl] Need Attributes From A InputStream
From: "Paul Brown" <prb@xxxxxxxxxxxxx>
Date: Thu, 17 Oct 2002 15:07:31 -0400
> From: Scott Purcell [mailto:spurcell@xxxxxxxxxxxxx]
> Subject: [xsl] Need Attributes From A InputStream
> I am receiving a InputStream which is a XML file. In the xml 
> file there are some attributes I want to grab, to put into a DB.

Parsing an InputStream or passing an InputStream into an XSLT processor is no big deal; in the XSLT case: ss = new<<your input stream here>>);

> I would like to grab the "width", "height", "copyright" and 
> "colorSpace", "transparency", "ditherAlgorithm" which come 
> from two differrent elements.

Here is one approach:

1) Wrap your InputStream in a StreamSource as above.
2) Write an XSLT stylesheet that converts the input XML document into a set of SQL statements (e.g., an INSERT statement).
3) Create a StreamResult that wraps a StringWriter.
4) Run the transformation against the StreamSource.
5) Collect the resulting SQL from the StringWriter and execute it against the target database.

Other approaches include writing your own SAX handler, but the XSLT approach is the simplest (and most appropriate to the list).

	-- Paul

 XSL-List info and archive:

Current Thread