Directory structure of generated code  Chapter 7: Using Message Bridge Samples

Chapter 6: Advanced Topics

Runtime location of schemas for validation

When creating instances of the generated classes from an XML input document, you can direct the binding framework to do validation. This requires that the XML document contains a declaration that identifies which schema to use for validation. For example, a DOCTYPE for DTDs or a xsi:noNamespaceSchemaLocation for XSDs. The runtime DataBean framework uses the following rules to locate the DTD.

StepsIf the SYSTEM keyword is specified:

  1. If the SYSTEM keyword specifies an absolute name, the framework tries to use the absolute path specified by the SYSTEM keyword.

  2. If the SYSTEM keyword specifies a relative name, the XML parser’s default location is used (usually the “current directory”).

  3. The framework parses the SYSTEM keyword to find the DTD name (removing any path information, if found), and tries to locate the DTD in one of the directories specified by the System property com.sybase.DataBean.EntityResolver.dtds, which can contain a semicolon-separated list of directories that will be successively searched for the DTD.

StepsIf the PUBLIC keyword is specified:

  1. If the PUBLIC keyword specifies an absolute name, the framework tries to use the absolute path specified by the PUBLIC keyword.

  2. If the PUBLIC keyword specifies a relative name, the XML parser’s default location is used (usually the “current directory”).

  3. The framework parses the PUBLIC keyword to find the DTD name (removing any path information, if found), and tries to locate the DTD in one of the directories specified by the System property com.sybase.DataBean.EntityResolver.dtds, which contains a semicolon-separated list of directories that will be successively searched for the DTD.

Most of the time, the name of the DTD will be specified in the DOCTYPE using the SYSTEM keyword. Again, most of the time, this name will be a “relative” name. For example, the following XML fragment indicates that the DTD name is recipe.dtd.

<!DOCTYPE recipe SYSTEM "recipe.dtd">

<recipe serves="10" region="n-america" type="snacks">

.

.

</recipe>

To ensure that the runtime framework can locate the DTD for validation, Sybase recommends that you put your DTDs in a directory (or directories) on the file system, and identify those directories through the System.property. This can be done in one of the following ways:





Copyright © 2005. Sybase Inc. All rights reserved. Chapter 7: Using Message Bridge Samples