1 / 12

XML Apache Tools Parsing and Transformation

XML Apache Tools Parsing and Transformation. Andy Clark. Apache XML Parsers. Xerces Versions available in Java, C++, and Perl* Xerces-J Supports various programming APIs JAXP, DOM, SAX, XNI Support standards XML+DTD, Namespaces, XML Schema, etc….

Download Presentation

XML Apache Tools Parsing and Transformation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML Apache ToolsParsing and Transformation Andy Clark 30 May 2002

  2. Apache XML Parsers • Xerces • Versions available in Java, C++, and Perl* • Xerces-J • Supports various programming APIs • JAXP, DOM, SAX, XNI • Support standards • XML+DTD, Namespaces, XML Schema, etc… * The Perl version is a wrapper on the C++ version.

  3. Xerces-J • Download • Location: http://xml.apache.org/dist/xerces-j/ • Packages: binary, source, and tools • NOTE: Users only need binary distribution • Contents • Jar files • xmlParserAPIs.jar, xercesImpl.jar, xercesSamples.jar • Documentation • Samples

  4. DOM samples dom.Counter dom.Writer …etc… SAX samples sax.Counter sax.DocumentTracer sax.Writer XNI samples xni.Counter xni.DocumentTracer xni.Writer …etc… Xerces-J Samples

  5. Xerces-J SAX Example #1 • sax.Counter 01 > java –cp xmlParserAPIs.jar;xercesImpl.jar;xercesSamples.jar sax.Counter data/personal.xml 02 data/personal.xml: 21 ms (38 elems, 20 attrs, 145 spaces, 128 chars)

  6. Xerces-J SAX Example #2 • sax.DocumentTracer 01 > java –cp xmlParserAPIs.jar;xercesImpl.jar;xercesSamples.jar sax.DocumentTracer data/personal.xml 02 setDocumentLocator(locator= {cut}) 03 startDocument() 04 startDTD(name="personnel", publicId=null, systemId="personal.dtd") 05 startEntity(name="[dtd]") 06 elementDecl(name="personnel", contentModel="(person)+") … 23 endDTD() 24 startElement(uri="", localName="personnel", qname="personnel", attributes={}) 25 ignorableWhitespace(text="\n\n ") 26 …

  7. Xerces-J SAX Example #3 • sax.Writer 01 > java –cp xmlParserAPIs.jar;xercesImpl.jar;xercesSamples.jar sax.Writer data/personal.xml 02 <?xml version="1.0" encoding="UTF-8"?> 03 <personnel> 04 05 <person contr="false" id="Big.Boss"> 06 <name><family>Boss</family> <given>Big</given></name> 07 <email>chief@foo.com</email> 08 <link subordinates="one.worker two.worker three.worker four.worker five.worker"></link> 09 <friend idref="f1"></friend> 10 </person> …

  8. Apache XSLT Transformers • Xalan • Versions available in Java and C++ • Xalan-J • Supports standard programming APIs • TrAX • Support standards • XSLT, XPath

  9. Xalan-J • Download • Location: http://xml.apache.org/dist/xalan-j/ • Packages: binary and source • NOTE: Users only need binary distribution • Contents • Jar files • NOTE: Bundles Xerces-J jar files • Documentation • Samples

  10. Xalan-J Example • org.apache.xalan.xslt.Process 01 > java –cp bin/xml-apis.jar;bin/xalan.jar;bin/xercesImpl.jar org.apache.xalan.xslt.Process –IN xdocs/sources/xalan/index.xml –XSL xdocs/style/stylesheets/document2html.xsl 02 <html> 03 <head> 04 <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> 05 <script src="resources/script.js" type="text/javascript“ language="JavaScript"></script> 06 <title>Xalan-Java version 2.3.0</title> …

  11. Useful Links • Apache XML Project • http://xml.apache.org/ • Xerces-J • http://xml.apache.org/xerces2-j/ • Xalan-J • http://xml.apache.org/xalan-j/

  12. XML Apache ToolsParsing and Transformation Andy Clark

More Related