相关疑难解决方法(0)

如果元素包含字母,如何写xslt?

Sth应该是所有字母或正则表达式[AZ].如何将xslt与正则表达式结合起来?

 <xsl:if test="string-contains(//ns0:elem/value, 'sth')">


        </xsl:if>
Run Code Online (Sandbox Code Playgroud)

regex xslt

6
推荐指数
1
解决办法
1万
查看次数

强制xslt使用版本2和xslCompiledTransform

我有以下xslt,我需要使用像'format-date'这样的xslt版本2.0函数.如何使用XsltCompiledTransform类(c#,.net 4.5)声明Xsl表使用2.0版.

 <xsl:stylesheet version="2.0"
               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               xmlns="http://www.w3.org/TR/xhtml1/strict"
               xmlns:msxsl='urn:schemas-microsoft-com:xslt' 
               xmlns:var='urn:var' 
               xmlns:JS='urn:JS'
                >
  <xsl:output method="html"/>
  <xsl:variable name="n" select="1"/>
  <xsl:template match="/NewDataSet">
    <html>
      <head>
        <style>
          table{border-collapse:collapse;font-family:"Verdana";}
          table,td{border:1px solid black;color:black; background-color:white;font-family:"Verdana";}
          table,th{border:1px solid balck;background-color:black;color:white;font-family:"Verdana"; }
          .rt{color:red;font-family:"Verdana";}
          .nt{color:black;font-family:"Verdana";}
          .redb{color:yellow; background-color:red;font-family:"Verdana";}
          .greenb{color:white;background-color:green;font-family:"Verdana";}
          .blackb{color:white;background-color:black;font-family:"Verdana";}
        </style>
        <title>EDI validation Result </title>
      </head>
      <body>
        <p class="nt">
          EDI validation result  of the PO <span class="rt"><xsl:value-of select="info/pono"/></span>
          received from <xsl:value-of select="info/CustomerName"/>.
        </p>

        <table>
           <th class="blackb" >Position</th>
          <th class="blackb"> Item Code </th>
          <th class="blackb">UoM</th>
          <th class="blackb"> Ordered Qty .</th>
          <th class="blackb">Ship Request</th>
          <th class="blackb"> Net-Quoted …
Run Code Online (Sandbox Code Playgroud)

c# xslt .net-4.5

3
推荐指数
2
解决办法
4751
查看次数

使用 XPath 选择包含特定类的表

我有一个 HTML 表,需要使用 XPath 选择它。该表可能包含也可能不包含多个类,但我只想要包含特定类的表。

以下是 HTML 片段示例:

<html>
  <body>
    <table class="no-border">
      <tr>
        <th colspan="2">Blah Blah Blah</th>
      </tr>
      <tr>
        <td>Content</td>
        <td>
          <table class="info no-border">
            <tr>
              <!-- Inner table content -->
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我需要使用 XPath 仅检索包含该类的表info。我尝试过使用/html/body/table/tr/td/table[@class='info*'],但这不起作用。我尝试检索的表可能存在于 HTML 文档中的任何位置 - 从技术上讲,不是任何位置,但外部表和内部表之间可能存在不同的层次结构级别。

如果有人能指出我正确的方向,我将不胜感激。

html xml xpath

2
推荐指数
1
解决办法
6705
查看次数

标签 统计

xslt ×2

.net-4.5 ×1

c# ×1

html ×1

regex ×1

xml ×1

xpath ×1