J
John Nilsen
Hello, hope you can help me with this little problem.
Below is my JSP-code.
It parses a XML-file. The parsing works just fine, but i'm have a
problem with using "if".
I want to check the variabel ${attrTypeTerminId} and find outh if the
value is 0. But i don't know how to represent it....
So again, the code works fine, except from the if-section. What is the
propper syntax?
##########################################
<%@ page language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<HTML>
<BODY>
<c:import var="xml" url="tekstvarsel_define.xml"/>
<xarse varDom="dom" xml="${xml}"/>
<x:forEach var="type" select="$dom/tekstvarsel/type">
<x:set var="attrTypeName"
select="string($type/@name)"/>
<p>Varseltype: <cut value="${attrTypeName}"/>
<x:forEach var="termin" select="termin">
<x:set var="attrTypeTerminId" select="string($termin/@id)"/>
<br> Termin: <cut
value="${attrTypeTerminId}"/>
<% if ( ${attrTypeTerminId} == 0 ) { %>
<p>YEEES: It has 0 as a value</p>
<% } else { %>
<p>NOOOO: It has <cut value="${attrTypeTerminId}"/> as a
value</p>
<% } %>
<x:forEach var="sted" select="sted">
<x:set var="dataTypeTerminSted"
select="string($sted/text())"/>
<br> Sted: <cut
value="${dataTypeTerminSted}"/>
</x:forEach>
</x:forEach>
</p>
</x:forEach>
<c:remove var="xml"/>
<c:remove var="dom"/>
</BODY>
</HTML>
Below is my JSP-code.
It parses a XML-file. The parsing works just fine, but i'm have a
problem with using "if".
I want to check the variabel ${attrTypeTerminId} and find outh if the
value is 0. But i don't know how to represent it....
So again, the code works fine, except from the if-section. What is the
propper syntax?
##########################################
<%@ page language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<HTML>
<BODY>
<c:import var="xml" url="tekstvarsel_define.xml"/>
<xarse varDom="dom" xml="${xml}"/>
<x:forEach var="type" select="$dom/tekstvarsel/type">
<x:set var="attrTypeName"
select="string($type/@name)"/>
<p>Varseltype: <cut value="${attrTypeName}"/>
<x:forEach var="termin" select="termin">
<x:set var="attrTypeTerminId" select="string($termin/@id)"/>
<br> Termin: <cut
value="${attrTypeTerminId}"/>
<% if ( ${attrTypeTerminId} == 0 ) { %>
<p>YEEES: It has 0 as a value</p>
<% } else { %>
<p>NOOOO: It has <cut value="${attrTypeTerminId}"/> as a
value</p>
<% } %>
<x:forEach var="sted" select="sted">
<x:set var="dataTypeTerminSted"
select="string($sted/text())"/>
<br> Sted: <cut
value="${dataTypeTerminSted}"/>
</x:forEach>
</x:forEach>
</p>
</x:forEach>
<c:remove var="xml"/>
<c:remove var="dom"/>
</BODY>
</HTML>