• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

DTD Required for XSL processing?

 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is an XML document required to have an associated DTD in order to be processed with an XSL stylesheet? Look at the example shown here, it doesn't appear that one is required. I just wanted to make sure that I'm interpreting this correctly.
Thanks,
Corey
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, XSL does not require that the document being transformed include a constraint, neither DTD nor XML-Schema. Validation to a constraint is purely a parsing issue, and XSLT deals with your XML as a structure of objects (similar to DOM), not as XML per se.
In fact, this is one crucial thing to remember when you're first studying XSLT. Don't think tags and values, think nodes in an object tree.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Validation to a constraint is purely a parsing issue...


So what does a DTD really do for you? I realize that it describes the various tags and what encapsulates what and so on, but when is it used and by what? You had mentioned that it had to do with parsing - do most parsers utilize the DTD in order to do their work? In order to edit an XML document using the XML DOM, is that XML document required to have an associated DTD or XML-Schema?
By the way, what is an XML-Schema? How is it different than a DTD? I've never heard of that term before...
Corey
[ January 15, 2002: Message edited by: Corey McGlone ]
 
Scott Bain
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A constraint (DTD or Schema) is a set of "the rules" about a given XML grammar. What elements are allowed, what attributes they can or must have, what sub-elements are contained within an element, etc...
Advantages:
Robustness - you check your documents against the constraint, they pass, you know they are valid and can be parsed (consumed) as you expect
Documents your intentions - If you specify that element x must contain 5 sub elements y, then someone reading the constraint knows this is a requirement, not just "it so happened" in a given XML instance.
Can establish defaults for attributes - Only in a DTD or schema can you establish default values for attributes.
Entites - you can define your own entities, like a copyright symbol for instance, in the contraint, then use the entity name in your XML document.
DTD is the older constraint system that comes to us from SGML. It is quite well established, but it itself is not written in XML (but rather in its own syntax). XML-Schema is a constraint system written in XML, so you can use all your existing XML tools to edit/validate/transform it. It has other advantages too, but is newer technology, so the support is spotty.
HTH!
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic