如何用 Schematron 替换特殊字符
How can I replace special characters with Schematron
如何替换属性中的特殊字符和空格?我尝试了各种正则表达式,但 none 中的正则表达式按方面工作。
<pattern id="setElementId">
<rule context="*[contains(@class, ' domain/element ') and boolean(@id)]">
<!-- Works, replaces 'a' -->
<let name="reqId" value="replace(@id, '[a]', '')"/>
<assert test="@id=$reqId" sqf:fix="setId">
The attribute "id" must comply with the given rules: "<value-of select="$reqId"/>"
</assert>
<sqf:fix id="setId">
<sqf:description>
<sqf:title>Set "id" to "<value-of select="$reqId"/>"</sqf:title>
<sqf:p>Set "id" to the calculated value.</sqf:p>
</sqf:description>
<sqf:replace match="@id" node-type="attribute" target="id" select="$reqId"/>
</sqf:fix>
</rule>
</pattern>
我想你最后的努力并没有后悔。
检查 CSS 编码:
Style {template.css}
从最终用户的示例中删除它,您就会得到答案!
<sqf:replace match="@id" node-type="attribute" target="id" select="$reqId"/>
</sqf:fix>
那没有 return 边值。
我使用 sergioFC 推荐的替换语句回答我自己的问题。
<pattern id="setElementId">
<rule context="*[contains(@class, ' topic/dlentry ') and boolean(@id) and descendant-or-self::*[contains(@class, ' ui-d/uicontrol ')]]" role="info">
<let name="reqId" value="descendant-or-self::*[contains(@class, ' ui-d/uicontrol ')]"/>
<let name="reqId" value="replace($reqId, 'ä', 'ae')"/>
<let name="reqId" value="replace($reqId, 'ö', 'oe')"/>
<let name="reqId" value="replace($reqId, 'ü', 'ue')"/>
<let name="reqId" value="replace($reqId, 'Ä', 'ue')"/>
<let name="reqId" value="replace($reqId, 'Ö', 'ue')"/>
<let name="reqId" value="replace($reqId, 'Ü', 'ue')"/>
<let name="reqId" value="replace($reqId, 'ß', 'ss')"/>
<let name="reqId" value="replace($reqId, '[^0-9a-zA-Z]', '')"/>
<assert test="@id=$reqId" sqf:fix="setId" role="warning">
The attribute "id" must comply with the given rules: "<value-of select="$reqId"/>"
</assert>
<sqf:fix id="setId">
<sqf:description>
<sqf:title>Set "id" to "<value-of select="$reqId"/>"</sqf:title>
<sqf:p>Set "id" to the calculated value.</sqf:p>
</sqf:description>
<sqf:replace match="@id" node-type="attribute" target="id" select="$reqId"/>
</sqf:fix>
</rule>
</pattern>
使用此模式,我可以根据后代 <uicontrol>
元素的值为 <dlentry>
元素生成 id
属性。
如何替换属性中的特殊字符和空格?我尝试了各种正则表达式,但 none 中的正则表达式按方面工作。
<pattern id="setElementId">
<rule context="*[contains(@class, ' domain/element ') and boolean(@id)]">
<!-- Works, replaces 'a' -->
<let name="reqId" value="replace(@id, '[a]', '')"/>
<assert test="@id=$reqId" sqf:fix="setId">
The attribute "id" must comply with the given rules: "<value-of select="$reqId"/>"
</assert>
<sqf:fix id="setId">
<sqf:description>
<sqf:title>Set "id" to "<value-of select="$reqId"/>"</sqf:title>
<sqf:p>Set "id" to the calculated value.</sqf:p>
</sqf:description>
<sqf:replace match="@id" node-type="attribute" target="id" select="$reqId"/>
</sqf:fix>
</rule>
</pattern>
我想你最后的努力并没有后悔。
检查 CSS 编码:
Style {template.css}
从最终用户的示例中删除它,您就会得到答案!
<sqf:replace match="@id" node-type="attribute" target="id" select="$reqId"/>
</sqf:fix>
那没有 return 边值。
我使用 sergioFC 推荐的替换语句回答我自己的问题。
<pattern id="setElementId">
<rule context="*[contains(@class, ' topic/dlentry ') and boolean(@id) and descendant-or-self::*[contains(@class, ' ui-d/uicontrol ')]]" role="info">
<let name="reqId" value="descendant-or-self::*[contains(@class, ' ui-d/uicontrol ')]"/>
<let name="reqId" value="replace($reqId, 'ä', 'ae')"/>
<let name="reqId" value="replace($reqId, 'ö', 'oe')"/>
<let name="reqId" value="replace($reqId, 'ü', 'ue')"/>
<let name="reqId" value="replace($reqId, 'Ä', 'ue')"/>
<let name="reqId" value="replace($reqId, 'Ö', 'ue')"/>
<let name="reqId" value="replace($reqId, 'Ü', 'ue')"/>
<let name="reqId" value="replace($reqId, 'ß', 'ss')"/>
<let name="reqId" value="replace($reqId, '[^0-9a-zA-Z]', '')"/>
<assert test="@id=$reqId" sqf:fix="setId" role="warning">
The attribute "id" must comply with the given rules: "<value-of select="$reqId"/>"
</assert>
<sqf:fix id="setId">
<sqf:description>
<sqf:title>Set "id" to "<value-of select="$reqId"/>"</sqf:title>
<sqf:p>Set "id" to the calculated value.</sqf:p>
</sqf:description>
<sqf:replace match="@id" node-type="attribute" target="id" select="$reqId"/>
</sqf:fix>
</rule>
</pattern>
使用此模式,我可以根据后代 <uicontrol>
元素的值为 <dlentry>
元素生成 id
属性。