From: ser@... (Sean Russell) Date: 2004-03-19T01:54:32+09:00 Subject: Re: REXML set default namespace Hans, I'm having a hard time understanding your problem, so I have some questions. Hans Fugal wrote in message news:... > Let me give more detail. I'm generating RSS with an xslt instruction like > this: .... > Now, given the following segment from the RSS: > > > > Google > > > > and the following segment from default.xsl: > What are you trying to do in the large picture? You say you're generating RSS, and it looks like you're transforming an RSS document; so: RSS --- XSL ---> RSS and you want to copy the contents of the description from one RSS to another. Is that correct? > The supposed solution[1] is to replace the xsl above with > Yes, that is what I'd recommend. copy-of should preserve the namespace, by the way, so if description is in the HTML namespace on input, it should also be in that namespace on output. > This doesn't work with the above example because the a tag gets a default > namespace of "", hence my question. In tests if I put the namespace in the Why is this a problem? It didn't have the HTML namespace in the original RSS, so why should it have the HTML namespace in the new RSS? And what does this have to do with REXML? So far, it looks like you're discussion XSL issues. > So as I see it there are two solutions: make the content of description > well-formed xml, e.g. by wrapping the whole thing in a div, or adding a > namespace or prefix to every element that is a child of description that > does not already have a namespace/prefix. The latter is what I'd like to > do, the former feels klugey. I can't figure out how to do the latter in > REXML though. Any ideas? At this point, I'm going to ignore the entire XSLT thread, because I don't see how it is relevant to using REXML to generate XML. Unless you're generating RSS that is the /input/ to the XSLT, in which case, we can still ignore the XSL, because all you care about is generating valid RSS, and the transformation questions are a separate issue. If the RSS spec requires you to place HTML content in the HTML namespace, then you have to do that when generating the RSS. Section 5.2 of the namespace specification says that all elements have a namespace that is the default namespace of the parent; EG:
the namespace of "a" is "html". This means that "adding a namespace or prefix to every element that is a child of description that does not already have a namespace/prefix" isn't practical, because elements inherit their namespace from their parent. Either there is a default namespace declared, or there isn't, and neither case will help you filter elements the way you want to. I doubt that I've answered any questions, because I don't think I understood the question in the first place, but perhaps we can clarify what exactly you're having trouble with. --- SER