This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Formatted output
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Fri, 27 Sep 2002 14:51:32 +0100
- Subject: RE: [xsl] Formatted output
- Reply-to: xsl-list at lists dot mulberrytech dot com
> But there is another hitch, I
cannot give commas to the traps.
Each BehaviourInfo has only one Trap/Name, so when you do
<xsl:for-each select="Trap/Name">
you are only processing one name, and it is always the last.
You need to insert the comma where you are processing the BehaviorInfo
elements, i.e. in the
<xsl:for-each select="//Behaviour/BehaviourInfo">
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of
> Satish, L. Gnanendra
> Sent: 27 September 2002 09:43
> To: 'xsl-list@lists.mulberrytech.com'
> Subject: RE: [xsl] Formatted output
>
>
> Hello Mike,
> > I have a xml such as this (which is shown simpler):
> >
> > <Behaviour>
> > <BehaviourInfo ID="1">
> > <Trap><Name>Trap1</Name></Trap>
> >
> <Message><Name>Msg1</Name><MessageLevel>Major</MessageLevel></Message>
> > </BehaviourInfo>
> > <BehaviourInfo ID="2">
> > <Trap><Name>Trap2</Name></Trap>
> >
> <Message><Name>Msg1</Name><MessageLevel>Minor</MessageLevel></Message>
> > </BehaviourInfo>
> > <BehaviourInfo ID="3">
> > <Trap><Name>Trap3</Name></Trap>
> >
> <Message><Name>Msg2</Name><MessageLevel>Cleared</MessageLevel>
> </Message>
> > </BehaviourInfo>
> > <BehaviourInfo ID="4">
> > <Trap><Name>Trap4</Name></Trap>
> >
> <Message><Name>Msg1</Name><MessageLevel>Critical</MessageLevel
> ></Message>
> > </BehaviourInfo>
> > </Behaviour>
>
> Also there is a seperate block,
> <Message>
> <MessageInfo ID="1">
> <Name>Msg1</Name>
> </MessageInfo>
> <MessageInfo ID="2">
> <Name>Msg2</Name>
> </MessageInfo>
> <MessageInfo ID="3">
> <Name>Msg3</Name>
> </MessageInfo>
> <Message>
>
> >
> > I would like an HTML output like:
> > "An alarm message is triggered by the traps 'trap1, trap2,
> > trap4' and will be cleared when the trap 'trap3' comes in."
>
> I have just given u an hypothetical example. The trap
> positions might vary
> and also there are no fixed number of traps.
> But I have solved it by using two template calls - one for
> the triggering
> alarms and another for the clearing alarms. But there is
> another hitch, I
> cannot give commas to the traps. This is called from the
> Message template:
>
> <xsl:template name="Call_MsgClearedBySystemFindTriggerTraps">
> <xsl:variable name="MsgName" select="Name"/>
> <xsl:for-each select="//Behaviour/BehaviourInfo">
> <xsl:variable name="BhvrMsgName"
> select="BehaviourMessages/BehaviourMessagesInfo/Name"/>
> <xsl:if test="$BhvrMsgName=$MsgName">
> <xsl:variable name="x"
> select="BehaviourMessages/BehaviourMessagesInfo/OIDInfo/Messag
> e/MessageInfo/
> MsgLevel[TextString='Cleared']"/>
> <-- !='Cleared' doesn't work -->
> <xsl:choose>
> <xsl:when test="$x">
> </xsl:when>
> <xsl:otherwise>
> <xsl:for-each select="Trap/Name">
> <B><I><xsl:value-of select="."/></I></B>
> <xsl:if test="position()<last()"><xsl:value-of
> select="$Comma"/></xsl:if>
> <-- Doesn't insert commas -->
> </xsl:for-each>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:if>
> </xsl:for-each>
> </xsl:template>
>
> This doesn't work the way I want.
>
> Thanx,
> Gnanendra.
>
> -----Original Message-----
> From: Michael Kay [mailto:michael.h.kay@ntlworld.com]
> Sent: Friday, September 27, 2002 1:49 PM
> To: xsl-list@lists.mulberrytech.com
> Subject: RE: [xsl] Formatted output
>
>
> You have asked this before. You haven't explained enough about how the
> input might vary. If the only thing that can vary is the
> content of the
> four <Name> elements, then it's trivially simple:
>
> <html>
> <p>An alarm messge is triggered by the traps
> '<xsl:value-of select="/Behaviour/BehaviourInfo[@ID=1]/Trap/Name"/>,
> <xsl:value-of select="/Behaviour/BehaviourInfo[@ID=2]/Trap/Name"/>,
> <xsl:value-of select="/Behaviour/BehaviourInfo[@ID=4]/Trap/Name"/>'
> and will be cleared when the trap
> '<xsl:value-of select="/Behaviour/BehaviourInfo[@ID=3]/Trap/Name"/>'
> comes in.</p>
> </html>
>
> If converting "Trap1" to "trap1" is an important characteristic of the
> transformation, you can do this using the substring() and translate()
> functions.
>
> - - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - -
> This e-mail and any attachments may contain information which is
> confidential, proprietary, privileged or otherwise protected
> by law. The
> information is solely intended for the named addressee (or a person
> responsible for delivering it to the addressee). If you are
> not the intended
> recipient of this message, you are not authorized to read,
> print, retain,
> copy or disseminate this message or any part of it. If you
> have received
> this e-mail in error, please notify the sender immediately by
> return e-mail
> and delete it from your computer.
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list