xsl-list
[Top] [All Lists]

Can I change the namespace of elements included via document()?

2003-06-02 08:09:44
I'm not sure the subject line is the best way to phrase this question.

Here's what I'm trying to do.

In my XHTML files, I have elements like this:

<div class="reuse">some_id</div>

(Please don't ask me why I didn't make some_id an attribute!)

I have a separate XML file called reusable.xml that looks like this:

        <entities xmlns="http://www.w3.org/1999/xhtml";>
                <entity id="some_id">
                        <p>Some HTML <code>tags</code> that might be needed
several times, so I create a reusable <q>entity</q>.</p>
                </entity>
        ...
        </entities>

To create a PDF out of my XHTML files, I'm using a customized version of the
Antenna House xhtml2fo.xsl.

To include the "reusable" entities, I use:

        <!-- Insert span.reuse and div.reuse content -->
        <xsl:template match="html:span[(_at_)class = 'reuse'] | 
html:div[(_at_)class =
'reuse']">
                <xsl:variable name="entity"
select="normalize-space(string(.))" />

                <xsl:apply-templates select="document('reusable.xml',
.)//html:entity[(_at_)id = $entity]" />

        </xsl:template>

This means I have to have an xmlns="http://www.w3.org/1999/xhtml"; attribute
on the <entities> element in reusable.xml.

I'd much rather do without this xmlns attribute.  However, the rest of
xhtml2f0.xsl contains templates for matching "html:p" and "html:code" (where
the <xsl:stylesheet> element has the attribute
xmlns:html="http://www.w3.org/1999/xhtml";).

Is there any way to bring the selected <entity> tag into the "html"
namespace "on the fly", so that the existing "html:p" templates will work,
without having to have that rather (to me) ugly
xmlns="http://www.w3.org/1999/xhtml"; attribute on the <entities> element in
reusable.xml?

Removing the xmlns attribute from the <entities> element would also save me
grief in XSLT processing for Web/.chm.

Graham Hannington

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>