O'Reilly logo

Building Oracle XML Applications by Steve Muench

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modularizing XML

XML entities and namespaces provide two techniques to modularize the contents of XML documents. In this section we study simple examples of both.

Including Text and External Resources

Entities are a mechanism for defining named string substitution variables in your XML file. They can save typing repetitive text in your documents. For example, if the Frequently Asked Questions document that we’re working on is for the Oracle JDeveloper 3.1 product, the text Oracle JDeveloper and the current version number of the product might appear in many of the questions and answers. We can define two entities to represent this repetitive text using the syntax:

<!ENTITY jdev "Oracle JDeveloper">
<!ENTITY ver  "3.1">

With these in place we can refer to the entities by name in the contents of our FAQ.xml document with the syntax:

<Question>What is the current version of &jdev;?</Question>
<Answer>The current version is &jdev; &ver;</Answer>

The syntax for user-defined entities is identical to that of the built-in entities we saw earlier (&lt;, &gt;, &apos;, and &quot;). References to user-defined entities like &jdev; start with an ampersand character and end with a semicolon, with the entity name in between. Like the default attribute values we saw earlier, these entities can be defined in an external DTD file, or right in the current document by including them in the local DTD section known as the internal subset . The syntax for including these entity definitions in the document ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required