xml - xsd restrict gYear between 1900 and this year? -
i new xml , wanna start simple moviedb. far got his:
<xs:element name="release"> <xs:simpletype> <xs:restriction base="xs:integer"> <xs:mininclusive value="1900"/> <xs:maxinclusive value="2016"/> </xs:restriction> </xs:simpletype> </xs:element>
how simpletype of gyear?
xsd 1.0
not possible. must test out-of-band wrt xsd.
xsd 1.1
possible using xs:assertion
, xpath 2.0 current-date()
function:
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:vc="http://www.w3.org/2007/xmlschema-versioning" vc:minversion="1.1"> <xs:element name="release"> <xs:simpletype> <xs:restriction base="xs:integer"> <xs:mininclusive value="1900"/> <xs:assertion test="$value le year-from-date(current-date())"/> </xs:restriction> </xs:simpletype> </xs:element> </xs:schema>
Comments
Post a Comment