Subject: Specifying namespaces with prefixes or URIs (Was: Re: [xsl] html tags in xml elements) From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 1 Mar 2002 09:55:15 +0000 |
Peter Davis wrote: > You might have an easier time using a Schema instead of a DTD, since > Schemas are more geared toward allowing combinations of multiple > namespaces. I'm not a Schema expert by any means, but I think you > could do: <xs:any namespace="##xhtml"> (where "xhtml" is the prefix > you use for the XHTML namespace). For what it's worth, the namespace attribute on xs:any actually takes the namespace URI rather than listing prefixes. So you probably need: <xs:any namespace="http://www.w3.org/1999/xhtml" minOccurs="0" maxOccurs="unbounded" processContents="lax" /> The minOccurs/maxOccurs state that any element can occur any number of times; the processContents indicates that the validator will only attempt validation if there's an element declaration for the element, and otherwise pass it without worrying. To steer the thread back onto XSLT territory, the difference between the XML Schema and XSLT's approach to indicating namespaces is intereating. In XML Schema, they always use the full namespace URI. In XSLT we use namespace prefixes (and the keyword #default) whenever we want to point to namespaces (e.g. exclude-result-prefixes, extension-element-prefixes, and namespace-prefix/result-prefix on xsl:namespace-alias). [In the current XSLT 2.0 Working Draft, there's one exception to this general rule - namely the default-xpath-namespace attribute which indicates the namespace URI used for elements named within expressions and patterns.] It's also interesting what this means in terms of validation of XSLT stylesheets by XML Schema and other schema languages that use XML Schema's type system (which includes RELAX NG and will include Schematron when XPath 2.0 starts being a reality). There isn't a XML Schema type called "xs:namespacePrefix", only xs:anyURI (a URI) and xs:QName (a qualified name). The lack of a "xs:namespacePrefix" type makes XSLT hard to validate, but more importantly some people object to qualified names in attributes because of the problems with canonicalisation. If prefixes are unimportant (which they're supposed to be), then you should be able to canonicalise to ns1, ns2 and so on. XML Schema at least partially solves that by indicating that such attributes are qualified names and therefore require special attention during canonicalisation. But no such indications are available for attributes listing namespace prefixes... Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] cocoon 2 and saxon, bernwardhanssen | Thread | Re: Specifying namespaces with pref, Peter Davis |
RE: [xsl] ?Dataislands?, Chris Bayes | Date | [xsl] element coordinates in html o, Ivanco Maros |
Month |