[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Need Attributes From A 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|