xsl-list
[Top] [All Lists]

RE: Parameter Manipulation

2005-04-27 06:22:05
Eugene,

Assuming that your input file is something like:

<?xml version="1.0" encoding="UTF-8"?>
<operations>
        <op op1="1" op2="1" op3="1"/>
        <op op1="1"/>
        <op op1="1" op2="0"/>
        <op op1="1" op2="1" op3="0"/>
        <op op2="0"/>
</operations>

Then the following XSLT will do what you want (at least as far as I
understand your question):

<?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" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:template match="/">
                <xsl:for-each select="operations/op">
                        <xsl:text>Operation #</xsl:text>
                        <xsl:value-of select="position()"/>
                        <xsl:text>: </xsl:text>
                        <xsl:for-each select="@*">
                                <xsl:value-of select="local-name()"/>
                                <xsl:choose>
                                        <xsl:when test=". = '0'">
                                                <xsl:text> Active </xsl:text>
                                        </xsl:when>
                                        <xsl:otherwise>
                                                <xsl:text> Non-active 
</xsl:text>
                                        </xsl:otherwise>
                                </xsl:choose>
                        </xsl:for-each>
                        <xsl:text>&#10;</xsl:text>
                </xsl:for-each>
        </xsl:template>
</xsl:stylesheet>

The output should be:

Operation #1: op1 Non-active op2 Non-active op3 Non-active
Operation #2: op1 Non-active
Operation #3: op1 Non-active op2 Active
Operation #4: op1 Non-active op2 Non-active op3 Active
Operation #5: op2 Active

If I am misunderstanding something (maybe you want something different) do
not hesitate to ask. Producing HTML/XML output can be done in a similar
manner.

I hope this helps.

Regards,
Angel


-----Original Message-----
From: jeb501(_at_)sanmargroup(_dot_)com 
[mailto:jeb501(_at_)sanmargroup(_dot_)com]
Sent: 27 April 2005 14:09
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Parameter Manipulation


Hi All,

I am having an xml file, from that I want to capture whether  all
operations/activited are

completeted or not using xsl.

could anybody help me to solve this.

here the operation completion is indicated by op1,op2,op3 with value "1"

and if it is "0" , the activity is not completed.

and some nodes have  one or two operations only.


<op op1="1" op2="1" op3="1"></op>

<op op1="1"></op>

<op op1="1" op2="0"></op>

<op op1="1" op2="1" op3="0"></op>

<op op2="0"></op>



Regards
Eugene

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


______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.
______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.
______________________

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