Nathan, Your question pertains only to XSLT, and not to libxml/libxslt. On Thu, Jun 22, 2006 at 10:06:14AM -0600, nathan bullock wrote: > xmlns="http://www.w3.org/1999/xhtml"> This namespace declaration puts all elements with no prefix in your *result tree* into the XHTML namespace (which is fine for XHTML output). > <!-- This almost works but creates poor namespace issues --> > <xsl:copy-of select="body/*"></xsl:copy-of> This rule copies all the child elements of the `body' element from the source tree verbatim; these elements are in the empty namespace, so your output properly declares the empty namespace as the default namespace for these elements. If you want to take all the child elements of the `body' element and place them in the XHTML namespace (that is, create new elements with the same local name and the XHTML namespace), then you will need a slightly more sophisticated approach that does this explicitly. For example: <!-- snippet --> <xsl:template match="body//node()|body//@*"> <!-- Copy anything that descends from the body element. --> <xsl:copy/> </xsl:template> <xsl:template match="body//*"> <!-- Override copying of element nodes. For element nodes, instead of copying, we create a new element with the same name and the desired namespace, then process its contents. --> <xsl:element name="{local-name(.)}" namespace="http://www.w3.org/1999/xhtml"> <xsl:apply-templates select="node()|@*"/> </xsl:element> </xsl:template> <!-- end snippet --> You'll then need to <xsl:apply-templates select="body/*"/> instead of your original copy statement in order to allow these templates to be applied. Take care, John L. Clark
Attachment:
pgpJrxAG4Nvol.pgp
Description: PGP signature