Re: Question about validation xml with xsd

This can't be done in XSD 1.0. In XSD 1.1 you can do it with assertions, 
for example you could write

<xs:element name="letter">
<xs:complexType>...</xs:complexType>
<xs:assert test="matches(string(.), 'Hi .*,\nYou have \d+ unpaid bill\.\n"/>
</xs:element>

Michael Kay
Saxonica


On 31/08/2011 17:50, Milena K wrote:
> Hi,
> I want to apologize in advance for my bad english.
>
> I want to validate xml(1), which is as follows:
>
> /<letter>
> Hi <name>Milena</name>,
> You have <count>1</count> unpaid bill.
> </letter>/
>
>
> The xsd must be:
>
> /<xsd:element name="letter">
> <xsd:complexType mixed="true">
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string"/>
> <xsd:element name="count" type="xsd:integer"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>/
>
> But If I have that xml(2):
>
> /<letter>
> Hi <name>Milena</name>,
> You have to give me <count>1</count> apple.
> </letter>/
>
> and If I try to validate this xml with the given xsd, the result will 
> be also OK.
> I want to restrict character data in mixed content.
> And If I have xml(2) instead of xml(1), I want to know that.
>
> My question is: How to write my xsd, so that validation of second xml 
> to be ERROR?
>
>
> Thank you in advance.
> Have a nice day!
>
> --
> Milena

Received on Monday, 5 September 2011 13:54:57 UTC