Chapter 4 XML Processing
141
For example, a multitier e business application that exchanges documents
with trading partners through a front end enforces document validity at the front
end. Not only does it check the validity of the document against its schema, but
the application also ensures that the document type is a schema type that it can
accept. It then may route documents to other applications or servers so that the
proper services can handle them. Since they have already been validated, the doc 
uments do not require further validation. In a Web service, validation of incoming
documents is typically performed in the interaction layer. Therefore, the process 
ing layer may not have to validate documents it receives from the interaction
layer. 
Some applications may have to receive documents that conform to different
schemas or different versions of a schema. In these cases, the application cannot
do the validation up front against a specific schema unless the application is given
a directive within the request itself about which schema to use. If no directive is
included in the request, then the application has to rely on a hint provided by the
document itself. Note that to deal with successive versioning of the same
schema where the versions actually modify the overall application's interface 
it sometimes may be more convenient for an application to expose a separate end 
point for each version of the schema.
To illustrate, an application must check that the document is validated against
the expected schema, which is not necessarily the one to which the document
declares it conforms. With DTD schemas, this checking can be done only after
validation. When using DOM, the application may retrieve the system or public
identifier (
SystemID
 or 
PublicID
) of the DTD to ensure it is the identifier of the
schema expected (Code Example 4.6), while when using SAX, it can be done on
the fly by handling the proper event. With JAXP 1.2 and XSD (or other non DTD
schema languages), the application can specify up front the schema to validate
against (Code Example 4.7); the application can even ignore the schema referred
to by the document itself.
public static boolean checkDocumentType(Document document,
String dtdPublicId) {
DocumentType documentType = document.getDoctype();
if (documentType != null) {
    String publicId = documentType.getPublicId();
    return publicId != null && publicId.equals(dtdPublicId);
}






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