문제

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