[xsd-users] Validation of element content against element tags

Moss, David R (SELEX Comms) (UK Christchurch) david.r.moss at selex-comm.com
Fri May 5 04:29:45 EDT 2006


All,

In an xml file I want to define some regular expressions (in the schema
they can just be string types, unless there is a way to enforce that the
content is a valid regular expression - is there a regular expression
for regular expressions...) and some composite expressions formed of the
basic elements (probably string lists in the schema):

<root>
	<basic>
		<firstSequence>[1-4][0-9]{2}</firstSequence>
		<secondSequence>[0-9]{5}</secondSequence>
		<thirdSequence>([9]+)</thirdSequence>
	</basic>
	
	<composite>
		<!- what's the best way to validate this? -->
		<compositeOne>thirdSequence firstSequence
secondSequence</compositeOne>
</composite>

</root>

The issue is in validating the composite content i.e. that elements with
those names in the list exist. I'm guessing one way to do it is, once
parsed into an xsd tree, to traverse the DOM node associated with the
'basic' type comparing each tag local name (firstSequence,
secondSequence etc) against the items in the list.

Having found a match I also want to get back to the xsd type which looks
feasible from reading some of the other posts here (each element of
'basic' being of the same type basic_t) :
DOMNode const* matched_basic_node = ...

xml_schema::type& t (
      *reinterpret_cast<xml_schema::type*> (
        matched_basic_node->getUserData(xml_schema::tree_node_key)));

    basic_t& b( dynamic_cast<basic_t&>(t) );


Is there a fundamentally different way of going about the list
validation - in an ideal world the content would be validated when the
xml is parsed in the first place, which I realise is unlikely due to the
seemingly bespoke nature of the problem.

Any help greatly appreciated.


Dave Moss
SELEX Communications
Grange Road
Christchurch 
Dorset  BH23 4JE
United Kingdom
Tel: + 44 (0) 1202 404841
Email: david.r.moss at selex-comm.com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codesynthesis.com/pipermail/xsd-users/attachments/20060505/0bcbcbe3/attachment.htm


More information about the xsd-users mailing list