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: Storing HTML in XML


On Thu, 6 Sep 2001 19:16:33 +0200 , you wrote:

>I would like to know if it's possible to store html code inside xml tags.

You can do this with Saxon's output-extension.

Regards - Michael Symonds

P.S. Example tested with Saxon 6.4.3 (the current version):

------------------- stylesheet ------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet  version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
       xmlns:saxon="http://icl.com/saxon";
       extension-element-prefixes="saxon" >

<xsl:output method="html" encoding="ISO-8859-1" /> 

<xsl:template match="HTML-file" >

 <xsl:variable name="outputfilename" >
   <xsl:value-of select="normalize-space(filename)" />
 </xsl:variable>

 <saxon:output href="{$outputfilename}.html" >
  <html>
        <xsl:apply-templates/>
  </html>
 </saxon:output>
</xsl:template>

<xsl:template match="filename" >
   <head>
     <title>
        <xsl:apply-templates/>
     </title>
   </head>
</xsl:template>

<xsl:template match="content" >
    <body>
        <xsl:apply-templates/>
    </body>
</xsl:template>

</xsl:stylesheet>
------------------- /stylesheet ------------------------

------------------- XML-data ------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<HTML-files>

<HTML-file>
  <filename>page1</filename>
  <content>Text of HTML-page 1</content>
</HTML-file>

<HTML-file>
  <filename>page2</filename>
  <content>Text of HTML-page 2</content>
</HTML-file>

<HTML-file>
  <filename>page3</filename>
  <content>Text of HTML-page 3</content>
</HTML-file>

</HTML-files>
------------------- /XML-data ------------------------

-------------- output-file no1:  page1.html ------------
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
      <title>page1</title>
   </head>
   <body>Text of HTML-page 1</body>
</html>
-------------- /output-file no1:  page1.html ------------


-------------- output-file no2:  page2.html ------------
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
      <title>page2</title>
   </head>
   <body>Text of HTML-page 2</body>
</html>
-------------- /output-file no2:  page2.html ------------

-------------- output-file no3:  page3.html ------------
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
      <title>page3</title>
   </head>
   <body>Text of HTML-page 3</body>
</html>
-------------- /output-file no3:  page3.html ------------


 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]