JAXP all content, part 2nd: Using the Sun's XML processing toolkit to transform XML

Source: Internet
Author: User
Tags xsl

In earlier versions of JAXP, the acronym represented the Java API for XML parsing. In the 1th part, JAXP is a layer on top of SAX and DOM that allows Java programmers to perform developer-neutral XML parsing. Initially, this is the full feature of JAXP. But the old saying is good, the past is the past, now is now.

In the past, the Java and XML combinations themselves were primarily used for parsing. The Java application simply reads the XML document and then processes the document's data by program. But as XML consumer applications become popular, it is clear that many of the operations performed by various applications overlap. For all good software, overlap leads to specifications (and new useful APIs are generated each time).

The first specification produced by the widespread use of XML is XSL. The application constantly extracts XML data, adds some formatting, and then displays it in the user interface-usually as HTML, XHTML, or WML. The XSL completes this task and builds the specification on it, allowing the application to discard all its proprietary conversion code. After the XSL specification is produced, the XML transformation API (transformation API for XML, TrAX) appears. TrAX provides a simple and consistent way to use XSL in a Java application. Currently, the last strand in the jaxp--(and intro) chain has been incorporated into the core Java development environment with TrAX. With all the developments and recent additions (such as extended validation and XPath support), JAXP now represents the Java API for XML processing. This article focuses on using JAXP for processing rather than parsing.

Interviewers

Understanding the basic flow of XSL is critical to mastering how JAXP handles transformations. If you are unfamiliar with XSL, you need to quickly review the basic XSL concepts. Even if you are an XSL expert, you have to endure my long-winded.

Source (XML)

When using XSL, you must start with XML. I know it sounds natural, but it's worth explaining. You may be accustomed to starting with an XML file (such as Phonebook.xml) and passing it to the XSL processor. JAXP not only allows you to pass files, it also allows you to do a lot of things, and in the next section, enter and output to learn about the content.

Style sheet (XSL)

An XSL style sheet that might be attractive to most designers. A style sheet is a collection of instructions that specifies a specific type of data as input and specifies another set of data and formatting as output. But remember, the stylesheet should operate on the structure of the inbound XML, rather than the specific data in the document. This ensures that the stylesheet handles any XML that is given to the frame, rather than a specific instance document.

Target (*ML)

Finally, remember that you can only output well-formed markup languages from XSL. You cannot export a Microsoft Word document or PDF. Be sure to use markup languages such as XML, XHTML, WML, or other good *ml (Markup language) variants.

Of course, I hear objections to this--I've seen applications that export PDFs from XML, or convert XML to Excel. Also, an engine that can accept a particular format of XML and convert it into a binary format does exist. But this is not part of the XSL domain; JAXP helps transform XML, but it is not allowed to be converted to binary format.

Input and output

With a simple review, you may have learned that many XML transformations are just about input and output. Import the XML, manipulate it, and then output *ml. Before dealing with all the middle bits (which I realize is the most interesting place), I'll show you how to enter the data into JAXP and how to return it to the output.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.