0
votes

I need to check the attribute value "id" of "book" (root) element.

If "id" value ends with three zeros(id="******-000") then the another attribute "book-type" should be "book" otherwise it should be "chapter".

Here is my xml looks like:

<book id="201019894-000" book-type="book" xsi:noNamespaceSchemaLocation="schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<book-meta>
<title-group>...

Is there any possibilities to check the above conditions in Schema(xsd).

Please guide me..

Thanks

1

1 Answers

1
votes

Can't be done in XSD 1.0.

In XSD 1.1 you can do this with an assertion such as

<xs:assert test="if (ends-with(@id, '-000') then @book-type='book' else @book-type='chapter'"/>