xsl-list
[Top] [All Lists]

Re: Group problem with blank elements

2005-06-30 23:48:13





Hi,
        Works fine for me. Iam using xalan.

Cheers,
prakash




                                                                                
                                                       
                      Mukul Gandhi                                              
                                                       
                      <mukul_gandhi(_at_)ya         To:      
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com                                
                
                      hoo.com>                 cc:      (bcc: 
omprakash.v/Polaris)                                                     
                                               Subject: Re: [xsl] Group problem 
with blank elements                                    
                      07/01/2005 11:38                                          
                                                       
                      AM                                                        
                                                       
                      Please respond                                            
                                                       
                      to xsl-list                                               
                                                       
                                                                                
                                                       
                                                                                
                                                       




I am sorry..

The real error is
-----------------
Error at xsl:apply-templates on line 67 of
file:/C:/xml/xsleg/xslt/posgroup1.xsl
:
  Invalid element within xsl:apply-templates:
Error at xsl:param on line 69 of
file:/C:/xml/xsleg/xslt/posgroup1.xsl:
  xsl:param must be immediately within a template,
function or stylesheet
Error at xsl:param on line 69 of
file:/C:/xml/xsleg/xslt/posgroup1.xsl:
  Variable is already declared in this template
Error at xsl:param on line 69 of
file:/C:/xml/xsleg/xslt/posgroup1.xsl:
  xsl:param must be the first element within a
template
Transformation failed: Failed to compile stylesheet. 4
errors detected.
Press any key to continue . . .

Regards,
Mukul

--- Mukul Gandhi <mukul_gandhi(_at_)yahoo(_dot_)com> wrote:

Hi Prakash,
  Your stylesheet look fine.. But when I run it with
Saxon 6.5.3, I get an error -

Error on line 2 column 6 of
file:/C:/xml/xsleg/xslt/posgroup1.xsl:
  Error reported by XML parser: The processing
instruction target matching "[xX]
[mM][lL]" is not allowed.
Transformation failed: Failed to parse stylesheet

Regards,
Mukul

--- omprakash(_dot_)v(_at_)polaris(_dot_)co(_dot_)in wrote:






Hi,

The following xslt 1.0 stylesheet should work with
a
little tweaking. If
there is an easier way to do this in 1.0, Iam not
aware of it. probably
much easier in xslt 2.0.

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

<xsl:output method="xml" indent="yes" />


<xsl:template match="/root">

<xsl:apply-templates select="statement-message[1]"
mode="wrap"/>

</xsl:template>

<xsl:template match="statement-message"
mode="wrap">


<xsl:apply-templates


select="following-sibling::*[1][self::statement-message][not(string-length(following-sibling::*[self::statement-message])

 = 0)][1]" mode="nowrap">
<xsl:with-param name="parent" select="."/>
<xsl:with-param name="dotag" select="0"/>
</xsl:apply-templates>

<!--
<xsl:apply-templates


select="following-sibling::*[1][self::statement-message]"
mode="nowrap"/>
-->


</xsl:template>

<xsl:template match="statement-message[. = '']">

<xsl:value-of select="'here'"/>

<xsl:apply-templates


select="following-sibling::*[1][self::statement-message]"
mode="wrap"/>
</xsl:template>



<xsl:template match="statement-message"
mode="nowrap">
<xsl:param name="parent"/>
<xsl:param name="dotag"/>


<xsl:choose>
<xsl:when test="number($dotag) = 0">

<statement-message>
<xsl:value-of select="$parent"/>
<xsl:value-of select="."/>

<xsl:choose>
<!--
<xsl:when


test="not(string-length(following-sibling::*[self::statement-message][1])
=
0)">
-->
<xsl:when test="not(string-length(.) = 0)">


<xsl:apply-templates


select="following-sibling::*[self::statement-message][not(string-length(following-sibling::*[self::statement-message])

 = 0)][1]" mode="nowrap">
<xsl:with-param name="parent" select="."/>
<xsl:param name="dotag" select="1"/>
</xsl:apply-templates>

</xsl:when>
<xsl:otherwise>

<xsl:apply-templates select="statement-message"/>
</xsl:otherwise>
</xsl:choose>

</statement-message>
</xsl:when>


<xsl:otherwise>

<xsl:value-of select="."/>
<xsl:apply-templates


select="following-sibling::*[self::statement-message][not(string-length(following-sibling::*[self::statement-message])

 = 0)][1]" mode="nowrap"/>
</xsl:otherwise>
</xsl:choose>

<xsl:choose>
<xsl:when


test="string-length(following-sibling::*[self::statement-message][1])
= 0">

<xsl:apply-templates


select="following-sibling::*[1][self::statement-message]"
mode="wrap"/>

</xsl:when>
</xsl:choose>



<!--
<xsl:apply-templates


select="following-sibling::*[self::statement-message][not(string-length(following-sibling::*[self::statement-message])

 = 0)][1]" mode="wrap"/>
-->


</xsl:template>

<xsl:template match="statement-message[. = '']">

<xsl:value-of select="'here'"/>

<xsl:apply-templates


select="following-sibling::*[1][self::statement-message]"
mode="wrap"/>

</xsl:template>


</xsl:stylesheet>


Hope this helps.

Cheers,
prakash











                      "Ed Yau"




                      <eyau(_at_)vstrading(_dot_)         To:

   <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>


                      co.uk>                   cc:

   (bcc: omprakash.v/Polaris)



Subject: [xsl] Group problem with blank elements


                      06/30/2005 11:00




                      PM




                      Please respond




                      to xsl-list


















Hiya,

Having loads of trouble with this.  On the face of
it a really easy
problem.
I have a bunch of elements like so:

<statement-message>Your account is now seriously
in
arrears.
To</statement-message>

<statement-message>avoid further action a payment
of</statement-message>

<statement-message>$82.00 is required immediately.
Any</statement-message>

<statement-message>purchases will now be
declined.</statement-message>

<statement-message>
</statement-message>

<statement-message>  More text
</statement-message>

<statement-message>
</statement-message>

<statement-message>
</statement-message>

<statement-message>
</statement-message>

I want to strip out the empty tags and merge
adjacent elements as
follows:

<statement-message> Your account is now seriously
in
arrears. To avoid
further action a payment of
82.00 is required immediately. Any purchases will
now be
declined.</statement-message>

<statement-message>  More text
</statement-message>

My code at the moment is:
<xsl:for-each-group select="statement-message"


group-ending-with="statement-message[string-length(normalize-space(follo
wing-sibling::statement-message[1]))=0]">
             <statement-message>
                         <xsl:value-of
select="."/>
             </statement-message>
</xsl:for-each-group>

My understanding of this is that it should start
grouping from the 1st
statement message, with the groups ending as soon
as
an empty element is
reached.  The empty tags at the end would still be
there, but at least
it should do the merge.  However, the result looks
like:

     <statement-message>Your account is now
seriously in arrears.
To</statement-message>
     <statement-message>
     </statement-message>
     <statement-message>  More text
</statement-message>
     <statement-message>
     </statement-message>
     <statement-message>
     </statement-message>
     <statement-message>
     </statement-message>

So where am I going wrong?

Ed




--~------------------------------------------------------------------
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>
--~--





This e-Mail may contain proprietary and
confidential
information and is sent for the intended
recipient(s) only.
If by an addressing or transmission error this
mail
has been misdirected to you, you are requested to
delete this mail immediately.
You are also hereby notified that any use, any
form
of reproduction, dissemination, copying,
disclosure,
modification,
distribution and/or publication of this e-mail
message, contents or its attachment other than by
its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in



--~------------------------------------------------------------------
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>
--~--






__________________________________
Yahoo! Mail
Stay connected, organized, and protected. Take the
tour:
http://tour.mail.yahoo.com/mailtour.html



--~------------------------------------------------------------------
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>
--~--






____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.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>
--~--





This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to 
you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, 
dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its 
attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

--~------------------------------------------------------------------
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>
--~--