Chapter 4 XML Processing
chain of filters and each filter implements a processing step. XML processing 
techniques such as SAX work well with this design. 
The two designs can, of course, be combined. When combined, transforma 
tions and identity transformations become handy techniques to use when the result
of a processing step cannot be directly wrapped into a 
 object compatible
with the next step. JAXP also provides support for chaining transformations with
the use of 
Code Example 4.10 illustrates an XML processing pipeline that combines
SAX and XSLT to validate an incoming purchase order document, extract on the 
fly the purchase order identifier, and transform the incoming document from its
external, XSD based schema to the internal, DTD based schema supported by the
business logic. The code uses a SAX filter chain as the 
 of a transforma 
tion. Alternatively, the code could have used a 
 to create
 to handle the transformation and then chain it to the
, which extracts the purchase order identifier.
public class SupplierOrderXDE extends 
XMLDocumentEditor.DefaultXDE {
public static final String DEFAULT_ENCODING = "UTF 8";
private XMLFilter filter;
private Transformer transformer;
private Source source = null;
private String orderId = null;
public SupplierOrderXDE(boolean validating, ...) {
// Create a [validating] SAX parser 
SAXParser parser = ...;
filter = new XMLFilterImpl(parser.getXMLReader()) {
// Implements a SAX XMLFilter that extracts the OrderID
// element value and assigns it to the orderId attribute
// Retrieve the style sheet as a stream
InputStream stream = ...;
// Create a transformer from the stylesheet
transformer = TransformerFactory.newInstance()
.newTransformer(new StreamSource(stream));
// Sets the document to be processed

New Page 1

Home : About Us : Network : Services : Support : FAQ : Control Panel : Order Online : Sitemap : Contact : Terms Of Service

java web hosting



 Our partners: | PHP: Hypertext Preprocessor | Best Web Hosting | Java Web Hosting | Inexpensive Web Hosting |

Jsp Web Hosting | Cheapest Web Hosting | Jsp Hosting | Cheap Hosting


Virtualwebstudio. Business web hosting division of Web Design Plus. All rights reserved