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: Testing the number of child elements


You only have one <apply> element with a <plus> child. The <xsl:for-each> is
being applied to the children of that <apply> element other than the first
and last. These are both <apply> elements (one is <apply><power> and the
other is <apply><times>). Both these <apply> elements have 3 children
(each). Therefore the test fails, and the otherwise branch is taken.

test="count(current()/child::*)=1" is correct, but it is a rather
complicated way of saying
test="count(*)=1".

> So I've written <ENTITY InvisibleTimes "&#E89E;">
You should have written <!ENTITY and &#xE89E;

Mike Kay

> -----Original Message-----
> From: Emmanuel Pietriga [mailto:emmanuel.pietriga@xrce.xerox.com]
> Sent: 10 February 2000 13:52
> To: XSL-List@mulberrytech.com
> Subject: Testing the number of child elements
> 
> 
> Hi.
> 
> Here's my problem: I want to test if the current node (plus) has one
> child or more   (I don't output the same thing if it has one child
> element or more than one). And I want to do this for all 
> elements "plus"
> of "apply" using a for-each.
> I am saying that current node is (plus) because I think it is 
> true when
> we are in the for-each loop. Am I right? That is, does current()
> actually returns the "plus" element?
> 
> Here is what I do, but it doesn't work  (XT always chooses the
> "otherwise" solution)
> 
> <xsl:template match="apply[plus]">
>   <xsl:for-each select="child::*[position()!=last() and
> position()!=1]">
>     <xsl:choose>
>     <xsl:when test="count(current()/child::*)=1">
>       <xsl:apply-templates select="."/><mo>+</mo>
>     </xsl:when>
>     <xsl:otherwise>
>       <mrow><xsl:apply-templates select="."/></mrow><mo>A</mo>
>     </xsl:otherwise>
>     </xsl:choose>
>   </xsl:for-each>
> </xsl:template>
> 
> 
> 
> The XML source is:
> <apply>
>   <eq/>
>   <apply>
>     <plus/>
>     <apply>
>       <power/>
>       <ci>x</ci>
>       <cn>2</cn>
>     </apply>
>     <apply>
>       <times/>
>       <cn>4</cn>
>       <ci>x</ci>
>     </apply>
>     <cn>4</cn>
>   </apply>
>   <cn>0</cn>
> </apply>
> 
> 
> Emmanuel.
> 
> By the way, I have another little question: I've included a DOCTYPE in
> my stylesheet because I define entity references in it.
> One of these entities is InvisibleTimes.  I know its unicode is E89E
> So I've written <ENTITY InvisibleTimes "&#E89E;">, but XT tells me
> "character not allowed"
> What can I Do?
> 
> 
> Thanks.
> 
> 
> --
> emmanuel.pietriga@xrce.xerox.com               |  Xerox 
> Research Centre Europe
> Document Model and Transformation Technologies |  6, Chemin 
> de Maupertuis
> +33 4 76 61 50 32  (direct)                    |  38240 Meylan, France
> +33 4 76 61 50 50  (switchboard)               |  
http://www.xrce.xerox.com




 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]