Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2008, 11:23 PM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default xsl transformation ...

hi,
I have an xml :
<richtext xmlns="http://www.lotus.com/dxl">
  <pardef id="2" align="full" leftmargin="1.3000in" />
  <par def="3" />
  <par def="3">LAM DING LING</par>
  <par def="3">Company Secretary</par>

<par def="2">
    <run>
      OVERSEA-CHINESE BANKING CORPORATION LIMITED</run>
  </par>

  <par def="3">
    <run>
      (Incorporated in Singapore
)</run>
  </par>
  <pardef id="4" leftmargin="1.3000in" rightmargin="7.3000in" />

  <par def="4">
    <run>
      CLARIFICATION OF 1996 COMPARATIVE FIGURES FOR THE EPS AND NTA PER SHARE IN THE 1997 HALF YEAR RESULTS ANNOUNCEMENT OF </run>
    <run>
      OVERSEA-CHINESE BANKING CORPORATION LIMITED</run>
    <run>

    </run>
  </par>

  <par def="7">
    <run>
      Elaine Tan</run>
  </par>
  <par def="7">
    <run>
      Secretary</run>
  </par>
  <par def="7">
    <picture height="255px" width="572px" scaledheight="2.6563in" scaledwidth="5.9583in">
      <par xmlns="">
        <run>&lt;img src= img onClick=OpenImageFile( D:\Corp_Annc_Attachment\Images\4825670D000B1BBD482 564F100353E96_AGEN-7JE3GZ_0.gif )&gt;&lt;/img&gt;</run>
      </par>
    </picture>
  </par>
 <par def="7">
    <run>
      Singapore, 12 August 1997</run>
  </par>
  <par def="7" />
</richtext>



i hav written an xsl :

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:template match="/">
        <html>
            <head>
                <title>SGX Announcements</title>
            </head>
            <body>
                <table class="TableMain" align="center">
                    <tr valign="middle">
                        <td class="LabelXSL" width="800">
                            JOINT-VENTURE
                        </td>
                    </tr>
                </table>
                <table align="center">
                    <xsl:template match="richtext">
                        <table>
                            <xsl:for-each select="par">
                                <xsl:for-each select="run">
                                    <xsl:apply-templates />
                                </xsl:for-each>
                                <br/>
                            </xsl:for-each>
                        </table>
                    </xsl:template>
                    <tr valign="middle">
                        <td class="LabelXSLO" width="800">
                            <xsl:template match="run">
                                <span>
                                    <xsl:value-of select="." />
                                </span>
                                <br />
                            </xsl:template>
                        </td>
                    </tr>
                </table>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>


 my html output format is:




<html>
    <head>
        <META http-equiv="Content-Type"
            content="text/html; charset=UTF-8">
            <title>SGX Announcements</title>
    </head>
    <body>
        <table class="TableMain" align="center">
            <tr valign="middle">
                <td class="LabelXSL" width="800">JOINT-VENTURE</td>
            </tr>
        </table>
        <table align="center">
            <table></table>
            <tr valign="middle">
                <td class="LabelXSLO" width="800">
                    <span>


                        LAM DING LING Company Secretary



                        OVERSEA-CHINESE BANKING CORPORATION LIMITED




                        (Incorporated in Singapore)














                        CLARIFICATION OF 1996 COMPARATIVE FIGURES FOR
                        THE EPS AND NTA PER SHARE IN THE 1997 HALF YEAR
                        RESULTS ANNOUNCEMENT OF

                        OVERSEA-CHINESE BANKING CORPORATION LIMITED

















                        The 1996 comparative figures of the earnings per
                        S$1 ordinary stock unit and the net tangible
                        asset backing per S$1 ordinary stock unit in the
                        1997 unaudited interim results announcement
                        dated 8 August 1997 were not adjusted for the
                        1-for-10 Rights Issue which was completed on 18
                        July 1996. After the adjustment for the Rights
                        Issue, the figures are as follows:












                        &lt;img src= img onClick=OpenImageFile(
                        D:\Corp_Annc_Attachment\Images\4825670D000B1BBD482 564F100353E96_AGEN-7JE3GZ_0.gif
                        )&gt;&lt;/img&gt;



                        Elaine Tan



                        Secretary



                        Singapore, 12 August 1997


                    </span>
                    <br>
                </td>
            </tr>
        </table>
    </body>
</html>


i need to show each value in a different line but i am getting all the values in a paragraph...

where to put exactly the <br> tag..

Thanks in advance...



 
Old September 29th, 2008, 02:39 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The output you show can't possibly be produced from this XSLT code. XSLT does not allow xsl:template declarations to appear anywhere except the top level of the stylesheet, so the only legitimate output from this code is an error message.

The other glaring error in your code is that all the elements in your source document are in a namespace, but you take no account of this when selecting them or matching them. Your stylesheet needs to declare a namespace such as xmlns:s="http://www.lotus.com/dxl" and then you need to use this in your match patterns and path expressions, for example <xsl:for-each select="s:par"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 29th, 2008, 03:15 AM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

thanks for the reply..
The namespace was declared wrongly i didnt add the prefix..

after transformation the html which i am getting is

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SGX Announcements</title>
</head>
<body>
<table class="TableMain" align="center">
<tr valign="middle">
<td class="LabelXSL" width="800">
                            JOINT-VENTURE
                        </td>
</tr>
</table>
<table align="center">
<table></table>
<br>LAM DING LINGCompany SecretaryOVERSEA-CHINESE BANKING CORPORATION LIMITED(Incorporated in Singapore)CLARIFICATION OF 1996 COMPARATIVE FIGURES FOR THE EPS AND NTA PER SHARE IN THE 1997 HALF YEAR RESULTS ANNOUNCEMENT OF OVERSEA-CHINESE BANKING CORPORATION LIMITEDThe 1996 comparative figures of the earnings per S$1 ordinary stock unit and the net tangible asset backing per S$1 ordinary stock unit in the 1997 unaudited interim results announcement dated 8 August 1997 were not adjusted for the 1-for-10 Rights Issue which was completed on 18 July 1996. After the adjustment for the Rights Issue, the figures are as follows:<img src= img onClick=OpenImageFile( D:\Corp_Annc_Attachment\Images\4825670D000B1BBD482 564F100353E96_AGEN-7JE3GZ_0.gif )></img>Elaine TanSecretarySingapore, 12 August 1997</table>
</body>
</html>


all the text in my run tags are displayed together.
i want each of my run tag to be dispayed in different lines..
i mean each run tag as seperate paragraph.

i think my previous post was something ........

Thanks in Advance..



 
Old September 29th, 2008, 04:07 AM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

hi kay,
i have removed my template tags inside my xsl and modified the same to the below one and its working fine..


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:strip-space elements="*" />
    <xsl:template match="richtext">
        <html>
            <head>
                <title>SGX Announcements</title>
            </head>
            <body>
                <table class="TableMain" align="center">
                    <tr valign="middle">
                        <td class="LabelXSL" width="800">
                            JOINT-VENTURE
                        </td>
                    </tr>
                </table>
                <table align="center">
                    <table>
                        <xsl:for-each select="par">
                            <xsl:for-each select="run">
                                <xsl:apply-templates />
                            </xsl:for-each>
                            <br />
                        </xsl:for-each>
                    </table>
                </table>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="run">
        <tr>
            <td>
                <span>
                    <xsl:value-of select="." />
                </span>
            </td>
        </tr>
    </xsl:template>
</xsl:stylesheet>










 
Old September 29th, 2008, 04:40 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I can't see why you would want to generate one <table> immediately inside another <table>.

I'm still surprised that it works. When you write this

       <xsl:for-each select="run">
           <xsl:apply-templates />
       </xsl:for-each>

you are applying templates to the children of the <run> element, not to the <run> element itself. This means your template rule for match="run" will not be invoked.

It would be more usual to replace the above with

       <xsl:apply-templates select="run"/>



Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 30th, 2008, 12:37 AM
Authorized User
 
Join Date: Sep 2008
Posts: 87
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi
updated my xsl to this

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*" />
<xsl:template match="richtext">
<html>
    <body>
    <table align="center">
    <xsl:for-each select="par">
<xsl:variable name="pathy" select="substring-before(substring-after(picture/par/run,'OpenImageFile('), ')') "/>

<a href="{$pathy}">
<xsl:value-of select="picture/par/run" disable-output-escaping="yes" /></a>
<xsl:for-each select="run">
<xsl:value-of select="." disable-output-escaping="yes" />
</xsl:for-each>
<br />
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

i think this looks fine are there any changes that i need to make.

i have kept

<xsl:for-each select="run">
<xsl:value-of select="." disable-output-escaping="yes" />
</xsl:for-each>

because i can have multiple run tags inside a par tag.

Thanks for helping
Raj






Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL-Transformation atulshin XSLT 4 September 15th, 2008 06:37 AM
WML and XSL transformation. Feodorov XSLT 2 February 13th, 2008 05:00 PM
XSL transformation problem kawal.singh XSLT 2 December 5th, 2006 05:58 AM
XSL Transformation problem dzyrd7 XSLT 2 November 23rd, 2006 01:24 PM
XSL transformation Thodoris XML 0 May 20th, 2004 08:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.