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

RE: Need Attributes From A InputStream

Subject: RE: Need Attributes From A InputStream
From: "Paul Brown" <prb@xxxxxxxxxxxxx>
Date: Thu, 17 Oct 2002 15:07:31 -0400
stringwriter inputstream
> From: Scott Purcell [mailto:spurcell@xxxxxxxxxxxxx]
> Subject:  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:

javax.xml.transform.stream.StreamSource ss = new javax.xml.transform.stream.StreamSource(<<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:  http://www.mulberrytech.com/xsl/xsl-list


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.