xsl-list
[Top] [All Lists]

RE: how to match true and false and display yes and no inst ead?

2005-07-27 12:18:15


__________________________________________________

Senior Programmer Analyst, Tax Distributed Systems Development

Tax & Compliance Development, ADP IT

Phone: (909) 592-6411 Ext. 3863

e-mail: adrian_rios(_at_)adp(_dot_)com



-----Original Message-----
From: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com] 
Sent: Wednesday, July 27, 2005 12:13 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] how to match true and false and display yes and no
instead?


Another way do this:

<xsl:template match="members/profile/married">
<xsl:if test=".='false'">no</xsl:if>
<xsl:if test=".='true'">yes</xsl:if>
</xsl:template>

is this:

<xsl:template match="members/profile/married[.='false']">no</xsl:template>
<xsl:template match="members/profile/married[.='true']">yes</xsl:template>

Also, the members/profile/ qualifier is probably redundant.

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


-----Original Message-----
From: Christian Rasmussen [mailto:byggemandbob(_at_)gmail(_dot_)com] 
Sent: 27 July 2005 18:49
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] how to match true and false and display 
yes and no instead?

Of course you are right... I was too fast making a sample xml. The
real xml-file I'm working on is too complex to post here, so its
better with a sample.

However, I've made a better sample and actually now it works: Here's
the solution:

do you have any comments to this? 
thank-you for respons anyway...

XML-FILE:
=======
<?xml version="1.0" encoding="UTF-8"?>
<members>
      <profile>
              <name>Bill Clinton</name>
              <married>false</married>
              <kid>joe</kid>
      </profile>
</members>


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

<xsl:template match="members">
members-template is matched!
<xsl:apply-templates select="profile/kid"></xsl:apply-templates>
</xsl:template>

<xsl:template match="members/profile/married">
<xsl:if test=".='false'">no</xsl:if>
<xsl:if test=".='true'">yes</xsl:if>
</xsl:template>

<xsl:template match="kid">
<xsl:apply-templates select="../married"></xsl:apply-templates>
kids-template is matched!
</xsl:template>

</xsl:stylesheet>









On 7/27/05, JBryant(_at_)s-s-t(_dot_)com <JBryant(_at_)s-s-t(_dot_)com> wrote:
Well, if you actually tried to run these templates, your 
XML parser should
spit out error messages.

You seem to be trying to use </xsl:apply-templates> to close
<xsl:template>, which isn't XML.

Assuming you mean

<xsl:template match="members">
xsl-fo goes here.....
</xsl:template>

then you want

<xsl:template match="members">
xsl-fo goes here.....
<xsl:apply-templates/>
</xsl:template>

Otherwise, the processor gets to members and stops, never 
processing the
children of members.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




Christian Rasmussen <byggemandbob(_at_)gmail(_dot_)com>
07/27/2005 11:57 AM
Please respond to
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com


To
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
cc

Subject
[xsl] how to match true and false and display yes and no instead?






Hi experts,

It seems to be a pretty simple question, but I'm newbie and I cannot
figure out how to do it :-(
please help me!

here is some sample xml showing my problem:

<members>
                 <profile>
                                 <name>Bill Clinton</name>
                                 <married>false</married>
                                 <kid>joe</kid>
                 </profile>
</members>


my xsl looks something like this:

<xsl:template match="members">
xsl-fo goes here.....
</xsl:apply-templates>

<xsl:template match="members/profile/married">
<xsl:if test=".='false'">no, he is not married</xsl:if>
<xsl:if test=".='true'">yes, he is married</xsl:if>
</xsl:apply-templates>

<xsl:template match="kid">
xsl-fo goes here.....
<xsl:apply-templates select="../married"></xsl:apply-templates>

I simply want to display "yes" and "no" instead of "true" 
and "false".
So I have made a template match which specifically matches 
the element
which holds the true or false value. After matching this element, I
test whether its true or false, and returns the text instead.

nothing shows up :-(

Thanx in advance for you help
/Christian


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



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

-----------------------------------------
This message and any attachments are intended only for the use of the
addressee and may contain information that is privileged and confidential.
If the reader of the message is not the intended recipient or an authorized
representative of the intended recipient, you are hereby notified that any
dissemination of this communication is strictly prohibited. If you have
received this communication in error, notify the sender immediately by
return email and delete the message and any attachments from your system.



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



<Prev in Thread] Current Thread [Next in Thread>
  • RE: how to match true and false and display yes and no inst ead?, Adrian_Rios <=