The soul is the mirror of an indestructible universeGottfried Wilhelm Leibniz
Relates to Web Standards and Java, XML Schema
The Sourceforge project XML Resume is an excellent tool for compiling a resume quickly in different formats (although I find the current document type definition slightly limited). It is well packaged and quick, and easy, to configure and run the examples with the Make utility, also offering some convenient filtering features. Unfortunately however, my personal resume was reluctant to build, with Xalan returning an ArrayIndexOutOfBounds exception.
Once I broke the XML instance apart, the error was soon tracked down. Using
XML Spy to create the instance, I had inadvertantly left empty values
in a couple of the level attributes for skill content. Since the attribute-list declaration in the DTD
is
<!ATTLIST skill level CDATA #IMPLIED>
the instance still validated, so I missed the error.
One resolution is to wrap the contents of the XSLT template for skill/@level within another conditional statement
that tests the length of the attribute value.
<xsl:template match="skill/@level">
<strong><xsl:if test="string-length() > 0"></strong>
[…]
<strong></xsl:if></strong>
</xsl:template>
However, this burden shouldn't fall to the transformation file, since it is the role of the Schema/DTD to define the contract for the instance. DTD syntax has no means to prevent this error, while in XML Schema it is simply a matter of defining a custom simple type.
<xsd:simpleType name="nonZeroString">
<xsd:restriction base="xsd:string">
<xsd:pattern value="\w.*"/>
</xsd:restriction>
</xsd:simpleType>
In this example the pattern facet requires the attribute value to be at least one word character. The facet <xsd:minLength value="1"/> serves the same
purpose sans regular expressions. An XML Schema shell has recently been posted in the project's forum.
Posted on Monday, Mar 01, 2004 at 05:15:57.
Comments on XML Resume Test Drive (0)