Re: using HTML tags in XML documents
Martin Honnen <[email protected]> Wed, 14 Mar 2007 14:41:13 +0100
| Newsgroups | gmane.comp.mozilla.devel.layout.xslt |
|---|---|
| Organization | Liberty Development |
| Message-ID | <[email protected]> |
[email protected] wrote: > I would like to be able to use tags like <html:br/> in my XML document > (http://l2f.noodley.com/xml/index.xml, they are commented out). > > I want a tag like the above to be the HTML equivalent of <br/> without > having to create a template for each and every tag. Is this possible? You can use XHTML element e.g. <page xmlns:xhtml="http://www.w3.org/1999/xhtml"> <news> <item> ... <xhtml:br/> </item> </news> </page> then you need a template to copy XHTML through (if the output is XML) or to convert them to HTML (if the output is HTML): <xsl:template match="item"> <li><xsl:apply-templates/></li> </xsl:template> <xsl:template xmlns:xhtml="http://www.w3.org/1999/xhtml" match="xhtml:*"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> respectively <xsl:template xmlns:xhtml="http://www.w3.org/1999/xhtml" match="xhtml:*"> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> -- Martin Honnen http://JavaScript.FAQTs.com/