Thread: Parse XML
View Single Post
  #4 (permalink)  
Old July 1st, 2009, 12:52 PM
mhkay's Avatar
mhkay mhkay is online now
Wrox Author
Points: 12,738, Level: 48
Points: 12,738, Level: 48 Points: 12,738, Level: 48 Points: 12,738, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,924
Thanks: 0
Thanked 82 Times in 80 Posts
Default

There's an enormous literature on managing code-lists but you seem to be looking for a cheap-and-cheerful solution. In that case you might like to use XML entities: write the schema as

Code:
<!DOCTYPE xs:schema [
  <!ENTITY codelist "codes.xml"/>
]>
<xs:schema>
  <xs:simpleType name="categories">
    <xs:restriction base="xs:normalizedString">
      &codelist;
    </xs:restriction>
  </xs:simpleType>
and parse it using a SAX parser with a custom EntityResolver. When the parser tries to find codes.xml it will call your EntityResolver and you can return anything you like.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
bribon (July 1st, 2009)