RE: [xsl] Selecting a descendant child at arbitrary depth

Subject: RE: [xsl] Selecting a descendant child at arbitrary depth
From: "Peter McEvoy" <pmcevoy@xxxxxxxx>
Date: Wed, 14 Mar 2001 11:05:13 -0000
Hi Jeni
	Thanks for your prompt reply.  I investigated what you suggested, below, and discovered that the
XHTML fragment (which is in fact an entire XHTML page included into the output of a servlet) has the
following as it's root element (the fragment - not the actual xml that the servlet generates):

<html xmlns="";>
**XHTML tags**
**more XHTML tags**
**Even more XHTML tags**

Needless to say, once I changed this declaration to a straigtforward <html>, ALL of the rules that I
had been trying, WORKED!  Arrggggg!

So now my next question to the list is to do with namespaces.  The servlet which generates the
output (which inturn is fed to a XSL servlet) does not specify any namespaces or even DTDs to
validate against:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

is the only "directive" type output in the header of the resultant XML. So really, the XSL engine
should have no concept of the context that the XML tags are occuring in - in fact, it shouldn't even
recognise that the tags are XHTML!  - So if this is true, how did it know that <html xmlns="...">
was changing the namespace?  (I'm a bit shaky on namespaces but I thought I had a working
knowledge).  Is the "xmlns" attribute a "protected keyword" attribute?  Is there any other attribute
names that I can't use?

So that's my general question, but a more specific one is: "How do I get the stylesheet to work with
or without (ignore) the namespace stuff?"  - Allow me to elaborate:

I need to "wrap" content in our websites "look and feel": I.E. navigation bars, menubars and the
like.  Without having to go a rewrite all the HTML that our current site has (and that all the web
applications produce), I have hit upon an idea which allows legacy content to still be displayed in
the legacy way, but allows me to "wrap" the relevant bits of the content with the sites look and
feel.  That idea is the "docBody" tag that I explained in my original post:

content producers "label" the page content that is important in their page with a <docBody> tag, and
my applicaiton can load it, ignore all their "navigation" type elements that may be in the <body> of
their HTML, and wrap my navigation elements, look and feel around.

Its a trivial solution that prevents a massive update of all the documents we have.  Anyway, we have
documents that may or may not have an "xmlns" declaration in their <html> tag - which obvioulsy
poses a problem from the above.

Is there a way to get the stylesheet to ignore these xmlns declarations?

Thanks once again for your insight, Jeni - I use your website all the time and infact learnt XSL
from it!


> It should work if you just have:
>   <xsl:template match="mainDisplay">
>     <xsl:copy-of select=".//docBody/*" />
>   </xsl:template>
> If that doesn't work, then I'd suspect a namespace issue (i.e. the
> docBody in the source XML is actually in a default namespace but
> you're trying to find one in the null namespace).

 XSL-List info and archive:

Current Thread