用于与XML解析器交互的特殊集合。它可以独立使用,作为validateDTD和validateSchema运算符的目标。否则,它必须包含有效的XPath表达式,然后将根据先前解析的XML DOM树对其进行计算。


SecDefaultAction log,deny,status:403,phase:2,id:90

SecRule REQUEST_HEADERS:Content-Type ^text/xml$ "phase:1,id:87,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML"

SecRule REQBODY_PROCESSOR "!^XML$" skipAfter:12345,id:88


SecRule XML:/employees/employee/name/text() Fred "id:89"

SecRule XML:/xq:employees/employee/name/text() Fred "id:12345,xmlns:xq=http://www.example.com/employees"


第一个XPath表达式不使用名称空间。 它将匹配有效负载,例如:


<employees>

   <employee>

       <name>Fred Jones</name>

       <address location="home">

           <street>900 Aurora Ave.</street>

           <city>Seattle</city>

           <state>WA</state>

           <zip>98115</zip>

       </address>

       <address location="work">

           <street>2011 152nd Avenue NE</street>

           <city>Redmond</city>

           <state>WA</state>

           <zip>98052</zip>

       </address>

       <phone location="work">(425)555-5665</phone>

       <phone location="home">(206)555-5555</phone>

       <phone location="mobile">(206)555-4321</phone>

   </employee>

</employees>


第二个XPath表达式确实使用名称空间。 它将匹配以下有效负载:


<xq:employees xmlns:xq="http://www.example.com/employees">

   <employee>

       <name>Fred Jones</name>

       <address location="home">

           <street>900 Aurora Ave.</street>

           <city>Seattle</city>

           <state>WA</state>

           <zip>98115</zip>

       </address>

       <address location="work">

           <street>2011 152nd Avenue NE</street>

           <city>Redmond</city>

           <state>WA</state>

           <zip>98052</zip>

       </address>

       <phone location="work">(425)555-5665</phone>

       <phone location="home">(206)555-5555</phone>

       <phone location="mobile">(206)555-4321</phone>

   </employee>

</xq:employees>


请注意第二个示例中使用的不同命名空间。



Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor