Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

xsl:copy-of working oddly?

1 view
Skip to first unread message

Daniel Cosuineau

unread,
Apr 5, 2008, 11:48:11 PM4/5/08
to
I'm relatively new to XSLT however I've noticed something weird.

I'm storing HTML in my XML for a content portion (probably not a great
idea but I need a flexible input type area). My XML looks as such: (in
the actual code content has 4 separate <p></p> groups with Lorem Ipsum
text inside)

---
<content>
<p>Lorem ipsum dolor sit amet, *snip*</p>
</content>
---

And my XSL file looks as suh:

---
*snip*

<p>Lorem ipsum dolor sit amet, *snip*</p>

<xsl:copy-of select="content/node()" />

*snip*
---

Everything renders properly in IE 7. The paragraphs are formatted
properly and the links are clickable.

HOWEVER, in Firefox (3 Beta 5 specifically) the paragraph in the XSL
(exactly the same tags as the first paragraph in the XML) is rendered
properly, where as the paragraphs included via the xsl:copy-of are
rendered very oddly. Font and color styles are applied, but display,
padding, margin, etc. are not. As well as the links :hover and other
properties work, but they aren't clickable.

Using the web developer tool bar to view the generated source,
everything looks as its supposed to (other than the paragraph tags
being given xmlns="" attributes).

Any ideas?

Martin Honnen

unread,
Apr 6, 2008, 6:33:57 AM4/6/08
to
Daniel Cosuineau wrote:

> Using the web developer tool bar to view the generated source,
> everything looks as its supposed to (other than the paragraph tags
> being given xmlns="" attributes).

Does your XSLT stylesheet generate XHTML? Then you can't simply copy the
'p' element in your XML to the output as it is in no namespace and not
in the XHTML namespace.
So you either need to fix the XML e.g.
<content>
<p xmlns="http://www.w3.org/1999/xhtml">...</p>
</content>
or you need to change the stylesheet e.g.
<xsl:apply-templates select="content/node()" mode="to-xhtml"/>

<xsl:template match="*" mode="to-xhtml">
<xsl:element name="{local-name()}"
namespace="http://www.w3.org/1999/xhtml">
<xsl:apply-templates select="@* | node()" mode="to-xhtml"/>
</xsl:element>
</xsl:template>

<xsl:template match="@* | text()" mode="to-xhtml">
<xsl:copy/>
</xsl:template>

--

Martin Honnen
http://JavaScript.FAQTs.com/

0 new messages