문제

Can i use #Required keyword in XML with enumerated value list?

like ,

<!ATTLIST item type CDATA (offer|request) "offer" #REQUIRED>

Thanks..

도움이 되었습니까?

해결책 3

I found it :) its not possible :) we can't use #required keyword with enumerated value lists in XML like

<!ATTLIST item type CDATA (offer|request) "offer" #REQUIRED>

I checked it with validator and it gives error with #REQUIRED ..

다른 팁

it's fine to have such combination like:

<!ATTLIST item type (offer|request) #REQUIRED>

But I'm not sure about CDATA definition in case of choice and also combination of default value and required is not ok. Try http://www.validome.org/grammar/validate/

Regards

JK.

No.

According to the XML Specification Attribute List Declarations you can declare atributes as

<!ATTLIST' element-name attribute-definitions* >

where attribute-definitions has the format

attribute-name attribute-type default-declaration

The attribute-type can be one of

  • CDATA
  • ID
  • IDREF
  • IDREFS
  • ENTITY
  • ENTITIES
  • NMTOKEN
  • NMTOKENS or
  • An enumeration of different NMTOKENS within parentheses separated by |.
    Ex: ( token1 | token2 | token3 ).

There are no other options.

Additionally, default-declaration allows one of the values:

  • #REQUIRED
  • #IMPLIED
  • #FIXED "fixed value"
  • "default value"

There are also no other options. So if you have CDATA, you can't have (offer|request), and if you have #REQUIRED you can't have #REQUIRED "offer" or "offer" #REQUIRED as you wrote. Some valid options, depending on what you want, are:

<!ATTLIST item type (offer|request) "request">
<!ATTLIST item type (offer|request) #REQUIRED>
<!ATTLIST item type CDATA "offer">
<!ATTLIST item type CDATA #REQUIRED>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top