Hello mates

i am having a problem designing a new DTD over the existing one found at:

http://dblp.uni-trier.de/xml/dblp.dtd

This is the DTD over their original XML file. I used a SAX parser to store specific data from the original file into my relational database.

Now i have to do the following: "Design a DTD to specify an XML document that consists of all publications in the conferences or journals that are co-authored by four specific authors Woo, Kin, Glas and Gert"

In few words what it needs is a DTD that is valid for if one of the 4 people is an author but how do i implement this restriction to 4 values only?

Dani AI

Generated

— two different problems are being conflated: (A) forcing an author element to be one of four fixed names, and (B) requiring a publication to contain at least one (or all) of those four authors. Plain DTDs are limited: you cannot enumerate allowed text values for an element, only for attribute values. was right to point toward attribute enumeration, but that implies changing the XML shape (author becomes an empty element with an enumerated attribute) or switching to a richer validation technology.

If changing the XML is acceptable, make author an empty element with an enumerated attribute. Example DTD fragment:

<!ELEMENT author EMPTY>
<!ATTLIST author id (Woo | Kin | Glas | Gert) #REQUIRED>

If you cannot change the XML shape (authors are element text), use an XML Schema (XSD) to enumerate element content:

<xs:element name="author">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:enumeration value="Woo"/>
      <xs:enumeration value="Kin"/>
      <xs:enumeration value="Glas"/>
      <xs:enumeration value="Gert"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

If the real requirement is to accept only publications that include at least one (or all) of the four people, neither DTD nor plain XSD handles that easily. Use Schematron or an XPath/XSLT/XQuery filter to express the co-occurrence rule. A simple Schematron assertion (XPath 1.0 style) that a publication has at least one of the four looks like:

<rule context="publication">
  <assert test="count(author[.='Woo' or .='Kin' or .='Glas' or .='Gert']) &gt; 0">
    Publication must include at least one of the four authors.
  </assert>
</rule>

Notes and cautions: DTD enumerations are token-based (no spaces) and brittle for real author names — prefer IDs or normalized identifiers if names vary. For maintainability, choose XSD or Schematron when you need value-level or cross-element checks. See the XML Schema and Schematron documentation for details: W3C XML, XML Schema Part 2, Schematron.

Recommended Answers

All 3 Replies

anyone?

plz provide me data about DBLP.......
i wana to project that technique.......

Here's a real answer. Look at the web pages below under the "Enumerated attribute values"

Use google and "enumerate DTD" and you'll find other examples. The idea is that you can use the <!ATTLIST> and make a list of valid strings that are allowed in those attributes. you should be able to adjust your <ATTLIST declarations in that DTD to restriction content for those authors and Conf/Journals.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.