首页 > 解决方案 > 添加 XSL:Stylesheet If Then Else

问题描述

我正在尝试对我在 CCure(访问控制系统)中为 LDAP 编写的查询使用选择、何时和否则语句。TEXT18 值应为“非活动”。Text12 值应为“False”。否则,从 LDAP 属性中提取数据并创建另一个列名“禁用”。希望这是有道理的,谢谢。

<?xml version ="1.0" encoding="utf8" ?>
<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" />
<!-- Parameters assigned at runtime. -->
<xsl:param name="paramCurrentTimestamp">20001231173010</xsl:param>
<xsl:param name="paramCurrentDT" >12/31/2000 5:30:10 PM</xsl:param>
<xsl:param name="paramCurrentCulture">en-US</xsl:param>
<!-- The transformation below provides trivial default copy of everything. -->
<xsl:template match="*|@*">
<xsl:choose>
<xsl:when Text18=”Inactive”&gt;<xsl:value-of select=”Inactive”/>.</xsl:when>
<xsl:when Text12=”False”&gt;<xsl:value-of select=”False”/>.</xsl:when>
<xsl:otherwise> "ucscPersonEmployeeStatus[text()='']">
<xsl:element name="Disabled">1</xsl:element>
<xsl:copy-of select="." />
</xsl:template>
<xsl:template match="@*">
  <xsl:copy />
</xsl:template>
<!-- End of customizable area. -->
</xsl:stylesheet>

标签: xsltattributes

解决方案


您忘记关闭</xsl:otherwise></xsl:choose>元素。修复这些样式表问题,以下可能对您有用:

<?xml version ="1.0" encoding="utf8" ?>
<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" />
    <!-- Parameters assigned at runtime. -->
    <xsl:param name="paramCurrentTimestamp">20001231173010</xsl:param>
    <xsl:param name="paramCurrentDT" >12/31/2000 5:30:10 PM</xsl:param>
    <xsl:param name="paramCurrentCulture">en-US</xsl:param>
    <!-- The transformation below provides trivial default copy of everything. -->
    <xsl:template match="*|@*">
        <xsl:choose>
            <xsl:when Text18="Inactive">
                <xsl:value-of select="Inactive"/>
            .</xsl:when>
            <xsl:when Text12="False">
                <xsl:value-of select="False"/>
            .</xsl:when>
            <xsl:otherwise> "ucscPersonEmployeeStatus[text()='']">
                <xsl:element name="Disabled">1</xsl:element>
                <xsl:copy-of select="." />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="@*">
        <xsl:copy />
    </xsl:template>
    <!-- End of customizable area. -->
</xsl:stylesheet>

推荐阅读