문제

Why the following code is not correct? XMLspy finds an error at element employee

<!ELEMENT personnel (contractor*,employee*,partner*)+ >
<!ELEMENT contractor (info)>
<!ELEMENT employee(info)>
<!ATTLIST info lname CDATA #REQUIRED fname CDATA #REQUIRED hiredate CDATA #REQUIRED firedate CDATA #REQUIRED>
도움이 되었습니까?

해결책

You need a space after employee.

The info element is also not defined.

If what you are trying to do is get the attributes on contractor and employee, then this does it:

<!ELEMENT personnel (contractor*, employee*, partner*)+ >
<!ELEMENT contractor EMPTY>
<!ELEMENT employee EMPTY>
<!ATTLIST contractor lname CDATA #REQUIRED fname CDATA #REQUIRED hiredate CDATA #REQUIRED firedate CDATA #REQUIRED>
<!ATTLIST employee lname CDATA #REQUIRED fname CDATA #REQUIRED hiredate CDATA #REQUIRED firedate CDATA #REQUIRED>

This is valid per the DTD above:

<personnel>
  <employee lname="Foo" fname="Bar" firedate="1" hiredate="2"/>
  <contractor lname="Foo" fname="Bar" firedate="1" hiredate="2"/>
</personnel>

Or you can share the attributes declaration like this:

<!ENTITY % shared "lname CDATA #REQUIRED fname CDATA #REQUIRED hiredate CDATA #REQUIRED firedate CDATA #REQUIRED">
<!ELEMENT personnel (contractor*, employee*, partner*)+ >
<!ELEMENT contractor EMPTY>
<!ELEMENT employee EMPTY>
<!ATTLIST contractor %shared;>
<!ATTLIST employee %shared;>

This way if you need to change the list of attributes, it will change for both contractor and employee.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top