<xsl:=“”if =“”>在java方法中使用XLST时无法正常工作

时间:2016-10-03 13:02:33

标签: java xls

以下是xml文件的XLST架构。我想在Bold中为特定的CUSTORMER字段显示CALLID字段。我尝试过XSL:IF并选择条件但不能转换。

    public StringReader getStyleSheet() {
            return new StringReader
             ("<html xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xsl:version=\"2.0\">"
             +"<body>"

             //+"<table cellspacing='0' border='1' width='100%'>"
             +"<table border='0' width='100%'>"
             +"<xsl:for-each select=\"//Table\">"
             +"  <tr bgcolor='#DDDDDD'>"
             +"  <td width='15%'><xsl:value-of select=\"ARRIVE\" /></td>"

  +"<xsl:if test=\"contains(CUSTOMER, 'dell')\">"        
          +"  <td><b><xsl:value-of select=\"CALLID\" /></b></td><td  width='40%' align='right'>"
         +"Order <input type='TEXT' size='2' maxlength='2' "
         +"name='seq{position()}' value='{position()}'/>"  
            // It took about 2 days to research this one line !!!
         +"</td></tr><tr>"
         +"  <td>Cust</td><td colspan='2'><xsl:value-of select=\"CUSTOMER\" /></td>"
         +"  </tr><tr>"
         +"  <td>Phone</td><td colspan='2'><xsl:value-of select=\"PHONE\" /> (<xsl:value-of select=\"CONTACT\" />)</td>"
         +"  </tr><tr>"
         +"  <td>Addr</td><td colspan='2'><xsl:value-of select=\"ADDRESS\" /></td>"
         +"  </tr><tr>"
         +"  <td>City</td><td colspan='2'><xsl:value-of select=\"CITY\" />"
         +" - <xsl:value-of select=\"POSTALCODE\" /></td>"
         +"  </tr><tr>"
         +"  <td>Appt</td>"
         +"  <td colspan='2'><xsl:value-of select=\"APPSTART\" />"
         +" - <xsl:value-of select=\"APPEND\" />"
         +" (<xsl:value-of select=\"ABSTAT\" />)</td></tr>"
         +"</xsl:if>" 
           +"</xsl:for-each>"

             +"</table>"
             +"</body>"
             +"</html>");
        }

这是示例xml数据;

CALLID>37875161</CALLID> 
  <ADDRESS>1 golden flake dr</ADDRESS> 
  <CITY>birmingham</CITY> 
  <TN>C</TN> 
  <MAP>Map</MAP> 
  <POSTALCODE>35205</POSTALCODE> 
  <STATE>AL</STATE> 
  <EZ>35203</EZ> 
  <ES>AL</ES> 
  <EC>Birmingham</EC> 
  <EA>1300 27th Place</EA> 
  <TPC>-86.819738;33.503489</TPC> 
  <EPC>-86.8085;33.5195</EPC> 
  <APPSTART>09/07 09:00am</APPSTART> 
  <APPEND>01:00pm</APPEND> 
  <ABSTAT>C</ABSTAT> 
  <CONTACT>jeff ross</CONTACT> 
  <PHONE>205 458 7322</PHONE> 
  <CUSTOMER>dell/golden flake</CUSTOMER> 

attached is the screen shot of the display page. the 8 digit number is there we call that CALLID that should be in bold character if the Cust field value is dell

0 个答案:

没有答案