Java Reference
In-Depth Information
um heat.</step>
<step>For each bread slice, smear one pat of mar-
garine on one side of
bread slice.</step>
<step>Place cheese slice between bread slices with
margarine-smeared
sides away from the cheese.</step>
<step>Place sandwich in frying pan with one
margarine-smeared size in
contact with pan.</step>
<step>Fry for a couple of minutes and flip.</step>
<step>Fry
other
side
for
a
minute
and
serve.</step>
</directions>
</recipe>
</recipeml>
Listing 10-12 specifies the grilled cheese sandwich recipe in Recipe Markup Lan-
guage (RecipeML) , an XML-based language for marking up recipes. (A company
named FormatData [see http://www.formatdata.com/ ]releasedthisformatin
2000.)
The document type declaration reports -//FormatData//DTD RecipeML
0.5//EN as the formal public identifier and http://www.formatdata.com/
recipeml/recipeml.dtd as the system identifier. Instead of keeping the default
mapping,let'smapthisformalpublicidentifierto recipeml.dtd ,asystemidentifier
for a local copy of this DTD file.
To create a custom entity resolver to perform this mapping, we declare a class that
implements the EntityResolver interface in terms of its InputSource re-
solveEntity(String publicId, String systemId) method. We then
use the passed publicId value as a key into a map that points to the desired sys-
temId value, and then use this value to create and return a custom InputSource .
Listing 10-13 presents the resulting class.
Listing 10-13. LocalRecipeML
import java.util.HashMap;
import java.util.Map;
Search WWH ::




Custom Search