Re: XSLT, XHTML, and default attribute values [somewha
Andrew Welch <ajwelch@xxxxxxxxxxxxxxx> writes: >> Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx> writes: >> >> > Only if your XML parser reads the DTD. If you can configure >> it not to >> > do so (and most have such a configuration option), then this won't >> > happen. >> >> that's true. but then why not just remove the DTD >> altogether? then you don't have to support obscure and/or >> parser dependant configuration options. > > I'm not sure it is true. If a DTD is specified in the xml the parser > *must* attempt to read it to ensure any defaulted values are present in > the XML, regardless of configuration. Turning off validation (I think) > simply suppresses validation errors. The only way I know of to parse an I happened to be using SAX, so I had already turned off validation using the standard SAX feature for this. with validation disabled, the DTD *was* still read, and default attribute values applied to the model. So you're correct there. but there may be additional parser-dependent switches that further restrict the behavior of the parser. at least, I think there can. the documentation for Xerces says that the feature: "http://apache.org/xml/features/nonvalidating/load-dtd-grammar" can be used to control this, but even with that feature disabled I was still getting the defaulted attribute values. so perhaps you're right. > I don't understand the benefits of using defaulted values, as anyone > studying the xml also needs to study the dtd to ensure they get the full > picture. Seems crazy, really. I can certainly see the value in some situations. They make sense in the "final" stage of document processing, when the doc is being read by some application to control some behavior, e.g. what to render to the screen. There seems to be a continuum of "levels of interest", from the basic lexical structure, to the "infoset" explicit in the document, to the type-annotated infoset, to the infoset augmented with default values. The problem is that there's no way to tell my tools what level I'm interested in. -- joe
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format