Examples of xsd:appinfo


Continuing from my previous post, https://buddhiraju.wordpress.com/2011/12/03/xsdannotations/ here a few real-world usecases where the xsd:appinfo is  put to good use.

For example, using xsd:appinfo you can override the default XML Schema to Java conversion logic applied by JAXB.

<xsd:simpleType name=”ZipCodeType”>
<xsd:annotation>
<xsd:appinfo>
<jxb:javaType name=”int”
parseMethod=”primer.MyDatatypeConverter.parseIntegerToInt”
printMethod=”primer.MyDatatypeConverter.printIntTo Integer” />
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base=”xsd:integer”>
<xsd:minInclusive value=”10000″/>
<xsd:maxInclusive value=”99999″/>
</xsd:restriction>
</xsd:simpleType>

JAXB infact uses XML schema appInfo elements extensively to control the Java XML mappings. More info here – http://docs.oracle.com/javaee/5/tutorial/doc/bnbbf.html

Microsoft SQL server uses appinfo at a document level to convery mapping information between the XML schemas corresponding to the DB schemas. http://msdn.microsoft.com/en-us/library/aa258678(v=sql.80).aspx

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sql="urn:schemas-microsoft-com:mapping-schema"> <xsd:annotation> <xsd:appinfo> <sql:relationship name="OrderOD" parent="Orders" parent-key="OrderID" child="[Order Details]" child-key="OrderID" /> </xsd:appinfo> </xsd:annotation>
Advertisements

About saratnathb

Building SOA solutions using Oracle Fusion Middleware technology stack.
This entry was posted in Uncategorized and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s