Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Rebol & XML

From: rebol:gavinmckenzie:fastmail:fm at: 8-Aug-2003 8:51

On Wed, 6 Aug 2003 15:03:10 +0200, "bryan" <[bry--itnisk--com]> said:
> >yeah I thought there might be problems, another problem is in the rare > >occurrence of namespace prefixed attributes. > > Actually considering not too rare in cases of xml coming out of > academia, or certain standards, where the xml namespace will be used, > especially in example like following: > > <?xml version="1.0"?> > <doc> > <p xml:lang="EN">Good Morning!</p> > <p xml:lang="EN-US">Howdy!</p> > </doc> > > note that the xml namespace does not need to be declared anywhere. >
Yeah, well the xml: namespace is special. It is implied. Though, there is acually a formal namespace URI for the xml namespace, so it *is* possible for it to be declared in an XML file. The xml namespace is only used for xml:lang and xml:space though. It is illegal for people to use this namespace other than for xml:lang and xml:space. Besides the xml namespace, others will be declared. Namespaces are tricky to implement in a parser/dom. The following snippets of XML are equivalent, though their syntax differs greatly: <a:a xmlns:a="whatever"> <b xmlns="something-else">text<b> </a:a> <a xmlns="whatever"> <b:b xmlns:b="something-else">text<b:b> </a> <a:a xmlns:a="whatever"> <a:b xmlns:a="something-else">text<a:b> </a:a> Note the nasty third example where the namespace prefix 'a' is redeclared locally for the element scope of 'b'. In short, for a namespace implementation the prefix: part of a namespace is almost entirely useless. It would be incorrect or at least very dangerous to build code that path-ed into an XML with an assumption about the prefixes: e.g. it would be bad to write a path like xml/a:a/b:b because the prefixes a: and b: are only present in one of the several ways to encode the same XML above. Gavin.