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?
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.