You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stefan Trcko <st...@aladin-eng.si> on 2003/05/09 11:41:20 UTC

taglibs and xsl problem

Hello

I have problem with xsl and taglibs-xtags.tld

This is my jsp file in which I connect to URL and then show styled data using xsl file.
My question is how to check that I can connect to this URL (real URL will not be localhost, this is just sample) and if i can't, write a message (e.g. Could not connect to URL).

<%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
<html><head><title></title></head>
<body bgcolor="white">
<font color="red">Info</font>
<xsltlib:style xml="http://localhost:8083/web/xml_sample.xml" xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
</body>
</html>


This is my xsl file, and my next question is how to test if "event" exists in xml file, because otherwise I want to write a message (e.g. No data). I try code below, but
when there is no "event" in the XML file, message "No data" is not written.


<xsl:choose>
<xsl:when test="event">
State 
<xsl:for-each select="event">
<xsl:value-of select="@entry"/>
<xsl:value-of select="@message" disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
No data
</xsl:otherwise>
</xsl:choose> 
</xsl:template>
</xsl:stylesheet>

This is my XML file with one event:

<?xml version="1.0" encoding="windows-1250" ?>
<info_xml lang="SLO">
<event id="32350" entry="08.05.2003 14:07" message="some text" />
</info_xml>
when there are no events the XML looks like:

<?xml version="1.0" encoding="windows-1250" ?>
<info_xml lang="SLO">
</info_xml>

Any ideas?

Thanks
Stefan

Re: taglibs and xsl problem

Posted by Stefan Trcko <st...@aladin-eng.si>.
Hello Mike

Thank you for trying my example with xml and xsl. 
I just run my example again with no modifications (with one "event" and with no "events" in the XML file and <xsl:when test="count(//event) &gt; 0">)
in the XSL file) and now everything works fine. I don't know how, I ran this example a couple of times last week, but
didn't work like I expect. So I didn't try your solution (because I can't modify XML document - it's not mine and it's on the other server).
But thanks,thanks again.

Stefan



----- Original Message ----- 
From: "Mike Jasnowski" <mj...@bea.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, May 09, 2003 4:17 PM
Subject: RE: taglibs and xsl problem


> Hmm, interesting, i just ran your stylesheet and xml document through XALAN
> 2.4 unchanged, it prints what you would expect.  I then changed the XML
> document "event" element to "events" and ran the transform again. This time
> "No data available" was printed, which is what I believe you were expecting
> right?
> 
> -----Original Message-----
> From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> Sent: Friday, May 09, 2003 9:42 AM
> To: Struts Users Mailing List
> Subject: Re: taglibs and xsl problem
> 
> 
> This is my complete xsl_sample.xsl file:
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xalan="http://xml.apache.org/xslt">
> <xsl:output method="html" omit-xml-declaration="yes"/>
> <xsl:variable
> name="icon-dir">http://localhost:8083/traffic/icons</xsl:variable>
> <xsl:template match="/">
> <xsl:apply-templates/>
> </xsl:template>
> <xsl:template match="info_xml">
> <table border="0" width="90%">
> <xsl:choose>
> <xsl:when test="count(event) &gt; 0">
> <tr>
> <td colspan="2" style="background: blue;font-family: Tahoma;font-size:
> 12;color: white;">
> Roads info
> </td>
> </tr>
> <xsl:for-each select="event">
> <tr>
> <td colspan="2" style="font-family: Tahoma;font-size: 12;font-style:
> italic;">
> <xsl:value-of select="@entry"/>
> </td>
> </tr>
> <tr>
> <td valign="top" width="40" align="center">
> <img src="{$icon-dir}/{@icon}" align="center" valign="top" border="0"/>
> </td>
> <td valign="top" style="font-family: Tahoma; font-size: 12px">
> <table width="23" height="14" cellpadding="0" cellspacing="0" border="0"
> align="left">
> <tr>
> <td background="{$icon-dir}/{@road_icon}" align="center" valign="middle"
> style="font-family: Tahoma; font-size: 9px"><xsl:value-of
> select="@road"/></td>
> </tr>
> </table>
> <xsl:value-of select="@message" disable-output-escaping="yes"/>
> </td>
> </tr>
> </xsl:for-each>
> </xsl:when>
> <xsl:otherwise>
> <tr>
> <td colspan="2" style="background: blue;font-family: Tahoma;font-size:
> 12;color: white;">No data available
> </td>
> </tr>
> </xsl:otherwise>
> </xsl:choose>
> </table>
> </xsl:template>
> </xsl:stylesheet>
> 
> 
> And this is the xml_sample.xml file:
> 
> <?xml version="1.0" encoding="windows-1250" ?>
> <info_xml lang="SLO">
> <event id="32350" entry="08.05.2003 14:07" road_icon="road_icon.gif"
> road="1" icon="icon.gif" message="some text" />
> </info_xml>
> 
> This is my JSP file:
> 
> <%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
> <html><head><title></title></head>
> <body bgcolor="white">
> <font color="red">Info</font>
> <xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
> xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
> </body>
> </html>
> 
> Thanks
> Stefan
> 
> 
> 
> ----- Original Message -----
> From: "Mike Jasnowski" <mj...@bea.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Friday, May 09, 2003 3:26 PM
> Subject: RE: taglibs and xsl problem
> 
> 
> > Is this <xsl:choose> in a template that is being instantiated?  I can't
> tell
> > from the snippet you posted where in your stylesheet this <xsl:choose> is.
> >
> > -----Original Message-----
> > From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> > Sent: Friday, May 09, 2003 9:13 AM
> > To: Struts Users Mailing List
> > Subject: Re: taglibs and xsl problem
> >
> >
> > I tryed your solution but when the xml file contains no "<event id="32350"
> > entry="date_time" message="some text" />" records, my jsp file still
> doesn't
> > write the message "No data available".
> >
> > Any idea?
> >
> > Thanks
> > Stefan
> >
> > ----- Original Message -----
> > From: "Mike Jasnowski" <mj...@bea.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Friday, May 09, 2003 2:20 PM
> > Subject: RE: taglibs and xsl problem
> >
> >
> > > You might try changing your <xsl:when> test to
> > >
> > >   <xsl:when test="count(//event) &gt; 0">
> > >
> > >  This assumes you want to count all "event" elements no matter where
> they
> > > occur in the XML document.
> > >
> > > HTH,
> > > Mike Jasnowski
> > >
> > > -----Original Message-----
> > > From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> > > Sent: Friday, May 09, 2003 5:41 AM
> > > To: struts-user@jakarta.apache.org
> > > Subject: taglibs and xsl problem
> > >
> > >
> > > Hello
> > >
> > > I have problem with xsl and taglibs-xtags.tld
> > >
> > > This is my jsp file in which I connect to URL and then show styled data
> > > using xsl file.
> > > My question is how to check that I can connect to this URL (real URL
> will
> > > not be localhost, this is just sample) and if i can't, write a message
> > (e.g.
> > > Could not connect to URL).
> > >
> > > <%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
> > > <html><head><title></title></head>
> > > <body bgcolor="white">
> > > <font color="red">Info</font>
> > > <xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
> > > xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
> > > </body>
> > > </html>
> > >
> > >
> > > This is my xsl file, and my next question is how to test if "event"
> exists
> > > in xml file, because otherwise I want to write a message (e.g. No data).
> I
> > > try code below, but
> > > when there is no "event" in the XML file, message "No data" is not
> > written.
> > >
> > >
> > > <xsl:choose>
> > > <xsl:when test="event">
> > > State
> > > <xsl:for-each select="event">
> > > <xsl:value-of select="@entry"/>
> > > <xsl:value-of select="@message" disable-output-escaping="yes"/>
> > > </xsl:for-each>
> > > </xsl:when>
> > > <xsl:otherwise>
> > > No data
> > > </xsl:otherwise>
> > > </xsl:choose>
> > > </xsl:template>
> > > </xsl:stylesheet>
> > >
> > > This is my XML file with one event:
> > >
> > > <?xml version="1.0" encoding="windows-1250" ?>
> > > <info_xml lang="SLO">
> > > <event id="32350" entry="08.05.2003 14:07" message="some text" />
> > > </info_xml>
> > > when there are no events the XML looks like:
> > >
> > > <?xml version="1.0" encoding="windows-1250" ?>
> > > <info_xml lang="SLO">
> > > </info_xml>
> > >
> > > Any ideas?
> > >
> > > Thanks
> > > Stefan
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 

RE: taglibs and xsl problem

Posted by Mike Jasnowski <mj...@bea.com>.
Hmm, interesting, i just ran your stylesheet and xml document through XALAN
2.4 unchanged, it prints what you would expect.  I then changed the XML
document "event" element to "events" and ran the transform again. This time
"No data available" was printed, which is what I believe you were expecting
right?

-----Original Message-----
From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
Sent: Friday, May 09, 2003 9:42 AM
To: Struts Users Mailing List
Subject: Re: taglibs and xsl problem


This is my complete xsl_sample.xsl file:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xslt">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:variable
name="icon-dir">http://localhost:8083/traffic/icons</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="info_xml">
<table border="0" width="90%">
<xsl:choose>
<xsl:when test="count(event) &gt; 0">
<tr>
<td colspan="2" style="background: blue;font-family: Tahoma;font-size:
12;color: white;">
Roads info
</td>
</tr>
<xsl:for-each select="event">
<tr>
<td colspan="2" style="font-family: Tahoma;font-size: 12;font-style:
italic;">
<xsl:value-of select="@entry"/>
</td>
</tr>
<tr>
<td valign="top" width="40" align="center">
<img src="{$icon-dir}/{@icon}" align="center" valign="top" border="0"/>
</td>
<td valign="top" style="font-family: Tahoma; font-size: 12px">
<table width="23" height="14" cellpadding="0" cellspacing="0" border="0"
align="left">
<tr>
<td background="{$icon-dir}/{@road_icon}" align="center" valign="middle"
style="font-family: Tahoma; font-size: 9px"><xsl:value-of
select="@road"/></td>
</tr>
</table>
<xsl:value-of select="@message" disable-output-escaping="yes"/>
</td>
</tr>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<tr>
<td colspan="2" style="background: blue;font-family: Tahoma;font-size:
12;color: white;">No data available
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
</table>
</xsl:template>
</xsl:stylesheet>


And this is the xml_sample.xml file:

<?xml version="1.0" encoding="windows-1250" ?>
<info_xml lang="SLO">
<event id="32350" entry="08.05.2003 14:07" road_icon="road_icon.gif"
road="1" icon="icon.gif" message="some text" />
</info_xml>

This is my JSP file:

<%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
<html><head><title></title></head>
<body bgcolor="white">
<font color="red">Info</font>
<xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
</body>
</html>

Thanks
Stefan



----- Original Message -----
From: "Mike Jasnowski" <mj...@bea.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, May 09, 2003 3:26 PM
Subject: RE: taglibs and xsl problem


> Is this <xsl:choose> in a template that is being instantiated?  I can't
tell
> from the snippet you posted where in your stylesheet this <xsl:choose> is.
>
> -----Original Message-----
> From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> Sent: Friday, May 09, 2003 9:13 AM
> To: Struts Users Mailing List
> Subject: Re: taglibs and xsl problem
>
>
> I tryed your solution but when the xml file contains no "<event id="32350"
> entry="date_time" message="some text" />" records, my jsp file still
doesn't
> write the message "No data available".
>
> Any idea?
>
> Thanks
> Stefan
>
> ----- Original Message -----
> From: "Mike Jasnowski" <mj...@bea.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Friday, May 09, 2003 2:20 PM
> Subject: RE: taglibs and xsl problem
>
>
> > You might try changing your <xsl:when> test to
> >
> >   <xsl:when test="count(//event) &gt; 0">
> >
> >  This assumes you want to count all "event" elements no matter where
they
> > occur in the XML document.
> >
> > HTH,
> > Mike Jasnowski
> >
> > -----Original Message-----
> > From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> > Sent: Friday, May 09, 2003 5:41 AM
> > To: struts-user@jakarta.apache.org
> > Subject: taglibs and xsl problem
> >
> >
> > Hello
> >
> > I have problem with xsl and taglibs-xtags.tld
> >
> > This is my jsp file in which I connect to URL and then show styled data
> > using xsl file.
> > My question is how to check that I can connect to this URL (real URL
will
> > not be localhost, this is just sample) and if i can't, write a message
> (e.g.
> > Could not connect to URL).
> >
> > <%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
> > <html><head><title></title></head>
> > <body bgcolor="white">
> > <font color="red">Info</font>
> > <xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
> > xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
> > </body>
> > </html>
> >
> >
> > This is my xsl file, and my next question is how to test if "event"
exists
> > in xml file, because otherwise I want to write a message (e.g. No data).
I
> > try code below, but
> > when there is no "event" in the XML file, message "No data" is not
> written.
> >
> >
> > <xsl:choose>
> > <xsl:when test="event">
> > State
> > <xsl:for-each select="event">
> > <xsl:value-of select="@entry"/>
> > <xsl:value-of select="@message" disable-output-escaping="yes"/>
> > </xsl:for-each>
> > </xsl:when>
> > <xsl:otherwise>
> > No data
> > </xsl:otherwise>
> > </xsl:choose>
> > </xsl:template>
> > </xsl:stylesheet>
> >
> > This is my XML file with one event:
> >
> > <?xml version="1.0" encoding="windows-1250" ?>
> > <info_xml lang="SLO">
> > <event id="32350" entry="08.05.2003 14:07" message="some text" />
> > </info_xml>
> > when there are no events the XML looks like:
> >
> > <?xml version="1.0" encoding="windows-1250" ?>
> > <info_xml lang="SLO">
> > </info_xml>
> >
> > Any ideas?
> >
> > Thanks
> > Stefan
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: taglibs and xsl problem

Posted by Stefan Trcko <st...@aladin-eng.si>.
This is my complete xsl_sample.xsl file:


<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:variable name="icon-dir">http://localhost:8083/traffic/icons</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="info_xml">
<table border="0" width="90%">
<xsl:choose>
<xsl:when test="count(event) &gt; 0">
<tr>
<td colspan="2" style="background: blue;font-family: Tahoma;font-size: 12;color: white;">
Roads info
</td>
</tr> 
<xsl:for-each select="event">
<tr>
<td colspan="2" style="font-family: Tahoma;font-size: 12;font-style: italic;">
<xsl:value-of select="@entry"/>
</td>
</tr> 
<tr> 
<td valign="top" width="40" align="center">
<img src="{$icon-dir}/{@icon}" align="center" valign="top" border="0"/> 
</td>
<td valign="top" style="font-family: Tahoma; font-size: 12px">
<table width="23" height="14" cellpadding="0" cellspacing="0" border="0" align="left">
<tr>
<td background="{$icon-dir}/{@road_icon}" align="center" valign="middle" style="font-family: Tahoma; font-size: 9px"><xsl:value-of select="@road"/></td>
</tr>
</table> 
<xsl:value-of select="@message" disable-output-escaping="yes"/>
</td> 
</tr>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<tr>
<td colspan="2" style="background: blue;font-family: Tahoma;font-size: 12;color: white;">No data available
</td>
</tr>
</xsl:otherwise>
</xsl:choose> 
</table>
</xsl:template>
</xsl:stylesheet>


And this is the xml_sample.xml file:

<?xml version="1.0" encoding="windows-1250" ?>
<info_xml lang="SLO">
<event id="32350" entry="08.05.2003 14:07" road_icon="road_icon.gif" road="1" icon="icon.gif" message="some text" />
</info_xml>

This is my JSP file:

<%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
<html><head><title></title></head>
<body bgcolor="white">
<font color="red">Info</font>
<xsltlib:style xml="http://localhost:8083/web/xml_sample.xml" xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
</body>
</html>

Thanks
Stefan



----- Original Message ----- 
From: "Mike Jasnowski" <mj...@bea.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, May 09, 2003 3:26 PM
Subject: RE: taglibs and xsl problem


> Is this <xsl:choose> in a template that is being instantiated?  I can't tell
> from the snippet you posted where in your stylesheet this <xsl:choose> is.
> 
> -----Original Message-----
> From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> Sent: Friday, May 09, 2003 9:13 AM
> To: Struts Users Mailing List
> Subject: Re: taglibs and xsl problem
> 
> 
> I tryed your solution but when the xml file contains no "<event id="32350"
> entry="date_time" message="some text" />" records, my jsp file still doesn't
> write the message "No data available".
> 
> Any idea?
> 
> Thanks
> Stefan
> 
> ----- Original Message -----
> From: "Mike Jasnowski" <mj...@bea.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Friday, May 09, 2003 2:20 PM
> Subject: RE: taglibs and xsl problem
> 
> 
> > You might try changing your <xsl:when> test to
> >
> >   <xsl:when test="count(//event) &gt; 0">
> >
> >  This assumes you want to count all "event" elements no matter where they
> > occur in the XML document.
> >
> > HTH,
> > Mike Jasnowski
> >
> > -----Original Message-----
> > From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> > Sent: Friday, May 09, 2003 5:41 AM
> > To: struts-user@jakarta.apache.org
> > Subject: taglibs and xsl problem
> >
> >
> > Hello
> >
> > I have problem with xsl and taglibs-xtags.tld
> >
> > This is my jsp file in which I connect to URL and then show styled data
> > using xsl file.
> > My question is how to check that I can connect to this URL (real URL will
> > not be localhost, this is just sample) and if i can't, write a message
> (e.g.
> > Could not connect to URL).
> >
> > <%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
> > <html><head><title></title></head>
> > <body bgcolor="white">
> > <font color="red">Info</font>
> > <xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
> > xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
> > </body>
> > </html>
> >
> >
> > This is my xsl file, and my next question is how to test if "event" exists
> > in xml file, because otherwise I want to write a message (e.g. No data). I
> > try code below, but
> > when there is no "event" in the XML file, message "No data" is not
> written.
> >
> >
> > <xsl:choose>
> > <xsl:when test="event">
> > State
> > <xsl:for-each select="event">
> > <xsl:value-of select="@entry"/>
> > <xsl:value-of select="@message" disable-output-escaping="yes"/>
> > </xsl:for-each>
> > </xsl:when>
> > <xsl:otherwise>
> > No data
> > </xsl:otherwise>
> > </xsl:choose>
> > </xsl:template>
> > </xsl:stylesheet>
> >
> > This is my XML file with one event:
> >
> > <?xml version="1.0" encoding="windows-1250" ?>
> > <info_xml lang="SLO">
> > <event id="32350" entry="08.05.2003 14:07" message="some text" />
> > </info_xml>
> > when there are no events the XML looks like:
> >
> > <?xml version="1.0" encoding="windows-1250" ?>
> > <info_xml lang="SLO">
> > </info_xml>
> >
> > Any ideas?
> >
> > Thanks
> > Stefan
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 

RE: taglibs and xsl problem

Posted by Mike Jasnowski <mj...@bea.com>.
Is this <xsl:choose> in a template that is being instantiated?  I can't tell
from the snippet you posted where in your stylesheet this <xsl:choose> is.

-----Original Message-----
From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
Sent: Friday, May 09, 2003 9:13 AM
To: Struts Users Mailing List
Subject: Re: taglibs and xsl problem


I tryed your solution but when the xml file contains no "<event id="32350"
entry="date_time" message="some text" />" records, my jsp file still doesn't
write the message "No data available".

Any idea?

Thanks
Stefan

----- Original Message -----
From: "Mike Jasnowski" <mj...@bea.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, May 09, 2003 2:20 PM
Subject: RE: taglibs and xsl problem


> You might try changing your <xsl:when> test to
>
>   <xsl:when test="count(//event) &gt; 0">
>
>  This assumes you want to count all "event" elements no matter where they
> occur in the XML document.
>
> HTH,
> Mike Jasnowski
>
> -----Original Message-----
> From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> Sent: Friday, May 09, 2003 5:41 AM
> To: struts-user@jakarta.apache.org
> Subject: taglibs and xsl problem
>
>
> Hello
>
> I have problem with xsl and taglibs-xtags.tld
>
> This is my jsp file in which I connect to URL and then show styled data
> using xsl file.
> My question is how to check that I can connect to this URL (real URL will
> not be localhost, this is just sample) and if i can't, write a message
(e.g.
> Could not connect to URL).
>
> <%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
> <html><head><title></title></head>
> <body bgcolor="white">
> <font color="red">Info</font>
> <xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
> xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
> </body>
> </html>
>
>
> This is my xsl file, and my next question is how to test if "event" exists
> in xml file, because otherwise I want to write a message (e.g. No data). I
> try code below, but
> when there is no "event" in the XML file, message "No data" is not
written.
>
>
> <xsl:choose>
> <xsl:when test="event">
> State
> <xsl:for-each select="event">
> <xsl:value-of select="@entry"/>
> <xsl:value-of select="@message" disable-output-escaping="yes"/>
> </xsl:for-each>
> </xsl:when>
> <xsl:otherwise>
> No data
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
> </xsl:stylesheet>
>
> This is my XML file with one event:
>
> <?xml version="1.0" encoding="windows-1250" ?>
> <info_xml lang="SLO">
> <event id="32350" entry="08.05.2003 14:07" message="some text" />
> </info_xml>
> when there are no events the XML looks like:
>
> <?xml version="1.0" encoding="windows-1250" ?>
> <info_xml lang="SLO">
> </info_xml>
>
> Any ideas?
>
> Thanks
> Stefan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: taglibs and xsl problem

Posted by Mike Jasnowski <mj...@bea.com>.
You might also be at the wrong context to check for the "event" element, For
example if the current context is root, but "event" is not a child of root,
doing something like <xsl:when test="count(event) &gt; 0">  will not find
it, but <xsl:when test="count(//event) &gt; 0"> would

-----Original Message-----
From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
Sent: Friday, May 09, 2003 9:13 AM
To: Struts Users Mailing List
Subject: Re: taglibs and xsl problem


I tryed your solution but when the xml file contains no "<event id="32350"
entry="date_time" message="some text" />" records, my jsp file still doesn't
write the message "No data available".

Any idea?

Thanks
Stefan

----- Original Message -----
From: "Mike Jasnowski" <mj...@bea.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, May 09, 2003 2:20 PM
Subject: RE: taglibs and xsl problem


> You might try changing your <xsl:when> test to
>
>   <xsl:when test="count(//event) &gt; 0">
>
>  This assumes you want to count all "event" elements no matter where they
> occur in the XML document.
>
> HTH,
> Mike Jasnowski
>
> -----Original Message-----
> From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> Sent: Friday, May 09, 2003 5:41 AM
> To: struts-user@jakarta.apache.org
> Subject: taglibs and xsl problem
>
>
> Hello
>
> I have problem with xsl and taglibs-xtags.tld
>
> This is my jsp file in which I connect to URL and then show styled data
> using xsl file.
> My question is how to check that I can connect to this URL (real URL will
> not be localhost, this is just sample) and if i can't, write a message
(e.g.
> Could not connect to URL).
>
> <%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
> <html><head><title></title></head>
> <body bgcolor="white">
> <font color="red">Info</font>
> <xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
> xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
> </body>
> </html>
>
>
> This is my xsl file, and my next question is how to test if "event" exists
> in xml file, because otherwise I want to write a message (e.g. No data). I
> try code below, but
> when there is no "event" in the XML file, message "No data" is not
written.
>
>
> <xsl:choose>
> <xsl:when test="event">
> State
> <xsl:for-each select="event">
> <xsl:value-of select="@entry"/>
> <xsl:value-of select="@message" disable-output-escaping="yes"/>
> </xsl:for-each>
> </xsl:when>
> <xsl:otherwise>
> No data
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
> </xsl:stylesheet>
>
> This is my XML file with one event:
>
> <?xml version="1.0" encoding="windows-1250" ?>
> <info_xml lang="SLO">
> <event id="32350" entry="08.05.2003 14:07" message="some text" />
> </info_xml>
> when there are no events the XML looks like:
>
> <?xml version="1.0" encoding="windows-1250" ?>
> <info_xml lang="SLO">
> </info_xml>
>
> Any ideas?
>
> Thanks
> Stefan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: taglibs and xsl problem

Posted by Stefan Trcko <st...@aladin-eng.si>.
I tryed your solution but when the xml file contains no "<event id="32350"
entry="date_time" message="some text" />" records, my jsp file still doesn't
write the message "No data available".

Any idea?

Thanks
Stefan

----- Original Message -----
From: "Mike Jasnowski" <mj...@bea.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, May 09, 2003 2:20 PM
Subject: RE: taglibs and xsl problem


> You might try changing your <xsl:when> test to
>
>   <xsl:when test="count(//event) &gt; 0">
>
>  This assumes you want to count all "event" elements no matter where they
> occur in the XML document.
>
> HTH,
> Mike Jasnowski
>
> -----Original Message-----
> From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
> Sent: Friday, May 09, 2003 5:41 AM
> To: struts-user@jakarta.apache.org
> Subject: taglibs and xsl problem
>
>
> Hello
>
> I have problem with xsl and taglibs-xtags.tld
>
> This is my jsp file in which I connect to URL and then show styled data
> using xsl file.
> My question is how to check that I can connect to this URL (real URL will
> not be localhost, this is just sample) and if i can't, write a message
(e.g.
> Could not connect to URL).
>
> <%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
> <html><head><title></title></head>
> <body bgcolor="white">
> <font color="red">Info</font>
> <xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
> xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
> </body>
> </html>
>
>
> This is my xsl file, and my next question is how to test if "event" exists
> in xml file, because otherwise I want to write a message (e.g. No data). I
> try code below, but
> when there is no "event" in the XML file, message "No data" is not
written.
>
>
> <xsl:choose>
> <xsl:when test="event">
> State
> <xsl:for-each select="event">
> <xsl:value-of select="@entry"/>
> <xsl:value-of select="@message" disable-output-escaping="yes"/>
> </xsl:for-each>
> </xsl:when>
> <xsl:otherwise>
> No data
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
> </xsl:stylesheet>
>
> This is my XML file with one event:
>
> <?xml version="1.0" encoding="windows-1250" ?>
> <info_xml lang="SLO">
> <event id="32350" entry="08.05.2003 14:07" message="some text" />
> </info_xml>
> when there are no events the XML looks like:
>
> <?xml version="1.0" encoding="windows-1250" ?>
> <info_xml lang="SLO">
> </info_xml>
>
> Any ideas?
>
> Thanks
> Stefan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: taglibs and xsl problem

Posted by Mike Jasnowski <mj...@bea.com>.
You might try changing your <xsl:when> test to

  <xsl:when test="count(//event) &gt; 0">

 This assumes you want to count all "event" elements no matter where they
occur in the XML document.

HTH,
Mike Jasnowski

-----Original Message-----
From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
Sent: Friday, May 09, 2003 5:41 AM
To: struts-user@jakarta.apache.org
Subject: taglibs and xsl problem


Hello

I have problem with xsl and taglibs-xtags.tld

This is my jsp file in which I connect to URL and then show styled data
using xsl file.
My question is how to check that I can connect to this URL (real URL will
not be localhost, this is just sample) and if i can't, write a message (e.g.
Could not connect to URL).

<%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
<html><head><title></title></head>
<body bgcolor="white">
<font color="red">Info</font>
<xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
</body>
</html>


This is my xsl file, and my next question is how to test if "event" exists
in xml file, because otherwise I want to write a message (e.g. No data). I
try code below, but
when there is no "event" in the XML file, message "No data" is not written.


<xsl:choose>
<xsl:when test="event">
State
<xsl:for-each select="event">
<xsl:value-of select="@entry"/>
<xsl:value-of select="@message" disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
No data
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

This is my XML file with one event:

<?xml version="1.0" encoding="windows-1250" ?>
<info_xml lang="SLO">
<event id="32350" entry="08.05.2003 14:07" message="some text" />
</info_xml>
when there are no events the XML looks like:

<?xml version="1.0" encoding="windows-1250" ?>
<info_xml lang="SLO">
</info_xml>

Any ideas?

Thanks
Stefan


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: taglibs and xsl problem

Posted by Mike Jasnowski <mj...@bea.com>.
In response to your first question,  you can write an XSLT extension
function that can attempt to connect to the URL passed as an argument to the
function. This extension function can return a result indicating whether you
were able to connect.   You might want to consider though doing this connect
before you attempt to process the stylesheet, and pass the result as a
parameter to the styleseheet.  Adding extension functions to stylesheets
does reduce the portability of them (this may not be a concern for you if
you're writing this stylesheet just for this purpose).

-----Original Message-----
From: Stefan Trcko [mailto:stefan.trcko@aladin-eng.si]
Sent: Friday, May 09, 2003 5:41 AM
To: struts-user@jakarta.apache.org
Subject: taglibs and xsl problem


Hello

I have problem with xsl and taglibs-xtags.tld

This is my jsp file in which I connect to URL and then show styled data
using xsl file.
My question is how to check that I can connect to this URL (real URL will
not be localhost, this is just sample) and if i can't, write a message (e.g.
Could not connect to URL).

<%@ taglib uri="/WEB-INF/tlds/taglibs-xtags.tld" prefix="xsltlib" %>
<html><head><title></title></head>
<body bgcolor="white">
<font color="red">Info</font>
<xsltlib:style xml="http://localhost:8083/web/xml_sample.xml"
xsl="/WEB-INF/templates/jsp/layouts/xsl_sample.xsl"/>
</body>
</html>


This is my xsl file, and my next question is how to test if "event" exists
in xml file, because otherwise I want to write a message (e.g. No data). I
try code below, but
when there is no "event" in the XML file, message "No data" is not written.


<xsl:choose>
<xsl:when test="event">
State
<xsl:for-each select="event">
<xsl:value-of select="@entry"/>
<xsl:value-of select="@message" disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
No data
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

This is my XML file with one event:

<?xml version="1.0" encoding="windows-1250" ?>
<info_xml lang="SLO">
<event id="32350" entry="08.05.2003 14:07" message="some text" />
</info_xml>
when there are no events the XML looks like:

<?xml version="1.0" encoding="windows-1250" ?>
<info_xml lang="SLO">
</info_xml>

Any ideas?

Thanks
Stefan


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org