如果我的条件为真,我想要做的就是跳过XSLT代码。我的条件是如果xml ControlPoint @ UserID ='Moo“并且如果ControlPoint = Save-Event或* Save-Sentence 跳过我在下面的xslt代码。 如何执行if语句或选择?
我的xslt代码
<?altova_samplexml c:\TEMP\temp11.xml?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="Integration/Case"/>
</xsl:template>
以上是我想跳过或在上述3个条件为真时不执行的代码 如果上述3个条件不成立,则执行此代码。
<!-- Check for Case event updates that should trigger a pass -->
<xsl:if test="//Integration/ControlPoint='SAVE-EVENT'">
<!-- Check for Discharge from Probation. Return whether or not BCA case or Charges Disposed -->
<xsl:for-each select="CaseEvent[(EventType/@Word='DISCHPROB')]">
<xsl:variable name="vEditCode">
<xsl:choose>
<xsl:when test="@Op='A'">A</xsl:when>
<xsl:when test="(@Op='E') and (Deleted='true')">D</xsl:when>
<xsl:when test="@Op='E'">E</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($vEditCode) > 0">
<NotificationEvent notificationType="BCADisposition">
<xsl:attribute name="bcaCaseIndicator"><xsl:value-of select="$vBCACase"/></xsl:attribute>
<xsl:attribute name="allChargesDisposedIndicator"><xsl:value-of select="$vAllChargesDisposed"/></xsl:attribute>
<xsl:attribute name="elementKey"><xsl:value-of select="@ID"/></xsl:attribute>
<xsl:attribute name="editCode"><xsl:value-of select="$vEditCode"/></xsl:attribute>
<xsl:text>CASE-EVENT-DISCHPROB</xsl:text>
</NotificationEvent>
</xsl:if>
</xsl:for-each>
<!-- -->
<!-- Check for repass events -->
<!-- -->
<xsl:if test="count(CaseEvent[(@Op='A') and (count(EventGroups/EventGroup[@Word='CCHSPECIAL'])!=0)])!=0">
<NotificationEvent notificationType="BCADisposition">
<xsl:attribute name="bcaCaseIndicator"><xsl:value-of select="$vBCACase"/></xsl:attribute>
<xsl:attribute name="allChargesDisposedIndicator"><xsl:value-of select="$vAllChargesDisposed"/></xsl:attribute>
<xsl:attribute name="elementKey"><xsl:value-of select="@ID"/></xsl:attribute>
<xsl:text>COURT-DATA-NOT-ORIGINALLY-PASSED</xsl:text>
</NotificationEvent>
</xsl:if>
</xsl:if>
以下是具有UserID =“MOO和ControlPoint = SAVE-EVENT 的xml文档 因此,在这种情况下,上面的代码应该被跳过,而不是由 XSLT代码
处理XML文档
<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="Disposition BCA Event" MessageID="65791751" xmlns="">
<ControlPoint Timestamp="11/6/2014 2:27:39 PM" UserID="MOO">SAVE-EVENT</ControlPoint>
<Case Op="E" InternalID="1617083662" ID="12116060" xmlns:user="http://tylertechnologies.com">
</Integration>
答案 0 :(得分:0)
尝试以下几点:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="Integration[not(ControlPoint/@UserID='MOO' and (ControlPoint='SAVE-EVENT' or ControlPoint='SAVE-SENTENCE'))]/Case"/>
</xsl:template>
<xsl:template match="Case">
<!-- code to apply -->
</xsl:template>
</xsl:stylesheet>
注意:XML区分大小写; “Moo”与“MOO”不同。