This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: How to embed HTMl tags within an XML file


A standard way to do this would be to designate special non-HTML elements in
a namespace.  Or, if you find that HTML elements are the exception rather
than the rule, you may wish to use the HTML namespace for them.  Either way,
if you put them in different namespaces, your stylesheet will be able to
always copy HTML elements, and do special things with the rest.

Source:
<html xmlns:special="http://foo.bar.com">
  <body>
    <table>
      <tr><td><special:content/></td></tr>
      <tr><td><special:content/></td></tr>
    </table>
  </body>
</html>

Stylesheet:
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:foo="http://foo.bar.com">

  <!-- Recursively copy all elements and attributes and their
children... -->
  <xsl:template match="*|@*">
    <xsl:copy>
      <xsl:apply-templates select="*|@*|text()"
    </xsl:copy>
  </xsl:template>

  <!-- ...except for elements in this namespace, which will require special
processing -->
  <xsl:template match="foo:*">
    <!-- Do special stuff for elements in this namespace -->
  </xsl:template>

</xsl:stylesheet>


Note that I used two different prefixes in the source and stylesheet
documents for the same namespace.  This is just to drill down the point that
it matters not what prefix is used or whether one is used at all (could be a
default namespace).  The stylesheet processor cares only about what
namespace an element or attribute is in, identified by the namespace URI,
not a prefix.  If the namespace URI is null, it's the same as saying the
element is "not in a namespace".

Hope this helps!  Feel free to ask any more specific questions if you need
to.

Evan Lenz
elenz@xyzfind.com
http://www.xyzfind.com
XYZFind, the search engine *designed* for XML
Download our free beta software: http://www.xyzfind.com/beta



-----Original Message-----
From: owner-xsl-list@mulberrytech.com
[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of pmitra
Sent: Thursday, September 28, 2000 12:30 PM
To: XSL-List@mulberrytech.com
Subject: How to embed HTMl tags within an XML file




I was wondering if anyone has any ideas on how to include tags like <LI>
or <P> or any other HTML tags in an XML file such that it will all be
extracted with the tags by the XSL and the generated HTML will format
the document using those tags.
I do not want to define particular tags in a DTD, I want to pass through
any generic HTMl tag, that any XML author may feel they want to put in:

For example,
In XML:

<UL>Items header
<LI>This is the first item
<LI>This is the second item
</UL>

How can I pass the whole above section as is through an XSL such that
HTMl can format this as a list?

Thanks,
Mila Mitra
pmitra@mail.arc.nasa.gov


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


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]