XSD : How to use ENTITY in XSD

xml, xsd, xslt

Solution

It looks to me like you're trying to declare some entities in your schema - this is not possible, entities must be declared in a DTD, not a schema.

The purpose of the `xsd:ENTITY` type is to declare that a particular attribute refers to an unparsed entity which has been declared in the document's DTD:

<!DOCTYPE example [
  <!NOTATION png SYSTEM "PNG">
  <!ENTITY photoOfIan SYSTEM "ian-photo.png" NDATA png>
]>
<example>
  <person name="Ian Roberts" picture="photoOfIan" />
</example>

I don't think it's possible to say in an XML schema that a particular attribute value must be a reference to a normal parsed entity, since the schema validates the content that you get after `&xxxxx;` entity references have been expanded.

Problem

XML ``` <copyright>&company; &department; &student_number; &developer;</copyright> ``` XSD ``` <xsd:element name="copyright" type="xsd:ENTITY"> <xsd:complexType> <xsd:sequence> <xsd:element ref="&copyright" /> <xsd:element ref="&department" /> <xsd:element ref="&student_number" /> <xsd:element ref="&developer" /> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="&copyright"> ..... ENTITY description ...... </xsd:element> ``` I try that. But Don't work.... How to use ENTITY in XSD?? I'm looking for the google, XML Book, ETC.. But I couldn't find....

Original source