Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl or dtd? (begginers question) 1

Status
Not open for further replies.

birney29

Programmer
Oct 11, 2001
140
GB
Hi,

just started trying to learn XML. I understand about the Syntax of tags ect, but i was wondering, if your using an xslt file to transform your xml, do you need a DTD? if so why?

thanks

Kenny.
 
the xsl stylesheet doesn't always need the xml file to come with a DTD. in fact, as you can imagine, it slows things down quite a bit. without it tho you can't really trust the xml - so if your xsl file assumes that there is an element <title> in every <book> it won't be able to throw an error if it's not there. but if you had a dtd with the xml it would make sure that every <book> did have a <title> before the xsl started to do anything.

i always set myself the rule that if i'm using a server to process xml (and my own scripts make the xml itself) i don't include the dtd because i can trust my own code - or rather i test my code with DTDs then remove them when it goes live.

if i'm writing xsl for client side processing i always give the DTD to the user, because they might not trust my xml and they probably don't notice the extra cpu time taken by checking the xml.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top