xsl-list
[Top] [All Lists]

RE: [xsl] Re: Formatting issue with HTML and TEXT output method

2008-07-17 10:09:01
Here is my sample xslt and xml .

You still haven't indicated what output you want.

html.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" omit-xml-declaration="no" indent="yes"/>

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

This template rule will never be fired because your code never does an
xsl:apply-templates call.

<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; 
charset=UTF-8"/> 

You shouldn't try to output a <meta> element, the HTML output method takes
care of that.

<title></title> </head> <body> <table 
width="100%"  valign="top"> <tr> <td colspan="2" 
style="text-align:justify;"> <xsl:value-of select="//name"/> 

It's better to select the name explicitly as select="/content/name".

</td></tr> <tr> <td colspan="2" style="text-align:justify;"> 
<xsl:copy-of select="//cond"/>

There's no such element as <cond> in HTML. Also, your <cond> element
contains an <html> element. So you're going to generate the structure:

<html>
  <body>
    <table>
      <tr>
        <td>
          <cond>
            <html>
              <body>
                <p>

This is not legal HTML, and I have no idea what the browser will do with it.


text.xsl

I really can't guess what output you are trying to produce with this code.
Generally if you output element nodes and then serialize using the text
output method, there's probably something wrong.

Michael Kay
http://www.saxonica.com/



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text" encoding="UTF-8" />

<xsl:template match="/content">
      <xsl:copy>
              <xsl:apply-templates />
      </xsl:copy>
</xsl:template>
<xsl:template match="/">
NAME <xsl:value-of select="//name"/>
<xsl:copy-of select="//cond"/>
</xsl:template>
</xsl:stylesheet>


content.xml


<content>
<name>
Senthil
</name>
<cond>
<html>
<body>
<p align="center">
TESTTESTTESTTESTTESTTESTTESTTESTTEST
TESTTESTTESTTESTTESTTESTTESTTESTTEST
TESTTESTTESTTESTTESTTESTTESTTESTTEST
</p>
<p align="center">
TESTTESTTESTTESTTESTTESTTESTTESTTEST
TESTTESTTESTTESTTESTTESTTESTTESTTEST
TESTTESTTESTTESTTESTTESTTESTTESTTEST
</p>
</body>
</html>
</cond>
</content>


Thanks,
Senthil

On Wed, Jul 16, 2008 at 4:38 PM, Senthilkumaravelan K 
<skumaravelan(_at_)googlemail(_dot_)com> wrote:
Hi All,
We have xml
<note>
<cond>
<html>
<body>
<p align="center">
TESTTESTTESTTESTTESTTESTTESTTESTTEST
TESTTESTTESTTESTTESTTESTTESTTESTTEST
TESTTESTTESTTESTTESTTESTTESTTESTTEST
</p>
<p align="center">
TESTTESTTESTTESTTESTTESTTESTTESTTEST
TESTTESTTESTTESTTESTTESTTESTTESTTEST
TESTTESTTESTTESTTESTTESTTESTTESTTEST
</p>
</body>
</html>
</cond>
<note>

When we write xslt one with "html" as output method and 
text as output method.

for html out method am using
<xsl:value-of select="//cond">

text output method
<xsl:copy-of select="//cond">


How to make the text xslt output like formatted text output pretty 
with alignment.

Any idea would of great help.

Thanks
Senthil


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--