質問

want to know if it possible in dtd to make of tree attribute required, but when one is used all other become optional :

<!ELEMENT train (CDATA) >

<!ATTLIST train seconds CDATA #REQUIRED !>
<!ATTLIST train minutes CDATA #REQUIRED !>
<!ATTLIST train hours CDATA #REQUIRED !>

I want to know how to make, when one is used the other attributes become optional

役に立ちましたか?

解決

You apply rules like that using DTD alone. You would have to use #IMPLIED in all attributes as suggested, and deal with that restriction in your code.

XML Schema 1.0 doesn't support that either, unless you use a standard extension such as Schematron, which allows assertions via XPath.

You can do that in XML Schema 1.1 using assertions (<xs:assert>, very similar to Schematron, although you might have trouble finding a parser which supports it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top