DNN表格&列出XSLT自定义

时间:2012-01-18 18:53:01

标签: xml xslt dotnetnuke

我正在使用DotNetNuke核心模块,Form和List,我需要帮助设计一个XSL表单

  1. 在用户使用jquery填写表单后隐藏表单;
  2. 在每个部分上方显示节点元素udt:fields / fieldname [if fieldType = separator]。
  3. 参见http://osnc.newsura.com/BenefitLogin.aspx

    的示例 联合国:雇主
    PW:密码

    XML完全符合我的需要。我要求帮助修改XSL样式表。

    XML CODE:

    <UserDefinedTable xmlns="DotNetNuke/UserDefinedTable">
      <Data>
        <UserDefinedRowId>10</UserDefinedRowId>
        <Blue_x0020_Shield />
        <Username_x0020__x0028_Blue_x0020_Shield_x0029_>fakeuser</Username_x0020__x0028_Blue_x0020_Shield_x0029_>
        <Password_x0020__x0028_Blue_x0020_Shield_x0029_>fakepassword</Password_x0020__x0028_Blue_x0020_Shield_x0029_>
        <Link_x0020__x0028_Blue_x0020_Shield_x0029_>fakelink</Link_x0020__x0028_Blue_x0020_Shield_x0029_>
        <Aetna />
        <Username_x0020__x0028_Aetna_x0029_>1</Username_x0020__x0028_Aetna_x0029_>
        <Password_x0020__x0028_Aetna_x0029_>2</Password_x0020__x0028_Aetna_x0029_>
        <Link_x0020__x0028_Aetna_x0029_>3</Link_x0020__x0028_Aetna_x0029_>
        <Principal_x0020_Financial_x0020_Dental />
        <Username_x0020__x0028_Principal_x0020_Financial_x0029_>4</Username_x0020__x0028_Principal_x0020_Financial_x0029_>
        <Password_x0020__x0028_Principal_x0020_Financial_x0029_>5</Password_x0020__x0028_Principal_x0020_Financial_x0029_>
        <Link_x0020__x0028_Principal_x0020_Financial_x0029_>6</Link_x0020__x0028_Principal_x0020_Financial_x0029_>
        <My_x0020_Secure_x0020_Advantage />
        <Username_x0020__x0028_My_x0020_Secure_x0020_Advantage_x0029_>7</Username_x0020__x0028_My_x0020_Secure_x0020_Advantage_x0029_>
        <Password_x0020__x0028_My_x0020_Secure_x0020_Advantage_x0029_>8</Password_x0020__x0028_My_x0020_Secure_x0020_Advantage_x0029_>
        <Link_x0020__x0028_My_x0020_Secure_x0020_Advantage_x0029_>9</Link_x0020__x0028_My_x0020_Secure_x0020_Advantage_x0029_>
        <Health_x0020_Butler />
        <Username_x0020__x0028_Health_x0020_Butler_x0029_>UN</Username_x0020__x0028_Health_x0020_Butler_x0029_>
        <Password_x0020__x0028_Health_x0020_Butler_x0029_>PW</Password_x0020__x0028_Health_x0020_Butler_x0029_>
        <Link_x0020__x0028_Health_x0020_Butler_x0029_>Link</Link_x0020__x0028_Health_x0020_Butler_x0029_>
        <FSA />
        <Username_x0020__x0028_FSA_x0029_ />
        <Password_x0020__x0028_FSA_x0029_ />
        <Link_x0020__x0028_FSA_x0029_ />
        <HSA />
        <Username_x0020__x0028_HSA_x0029_>13</Username_x0020__x0028_HSA_x0029_>
        <Password_x0020__x0028_HSA_x0029_>14</Password_x0020__x0028_HSA_x0029_>
        <Link_x0020__x0028_HSA_x0029_>15</Link_x0020__x0028_HSA_x0029_>
        <Created_x0020_by>Jason Hollis</Created_x0020_by>
        <Created_x0020_at>2012-01-12T15:02:47-08:00</Created_x0020_at>
        <Changed_x0020_by>Jason Hollis</Changed_x0020_by>
        <Changed_x0020_at>2012-01-17T16:47:11-08:00</Changed_x0020_at>
        <EditLink>http://osnc.newsura.com/BenefitLogin/tabid/275/ctl/edit/mid/898/Default.aspx?UserDefinedRowId=10</EditLink>
        <Created_x0020_by_UDT_Original>host</Created_x0020_by_UDT_Original>
        <Created_x0020_by_UDT_Caption>Jason Hollis</Created_x0020_by_UDT_Caption>
        <Created_x0020_at_UDT_Value>&lt;!--063461977367--&gt;1/12/2012 3:02 PM</Created_x0020_at_UDT_Value>
        <Created_x0020_at_UDT_Ticks>634619773670000000</Created_x0020_at_UDT_Ticks>
        <Changed_x0020_by_UDT_Original>host</Changed_x0020_by_UDT_Original>
        <Changed_x0020_by_UDT_Caption>Jason Hollis</Changed_x0020_by_UDT_Caption>
        <Changed_x0020_at_UDT_Value>&lt;!--063462415631--&gt;1/17/2012 4:47 PM</Changed_x0020_at_UDT_Value>
        <Changed_x0020_at_UDT_Ticks>634624156310000000</Changed_x0020_at_UDT_Ticks>
      </Data>
    
    
        <Fields>
        <UserDefinedFieldId>80</UserDefinedFieldId>
        <ModuleID>898</ModuleID>
        <FieldTitle>Blue Shield</FieldTitle>
        <Required>false</Required>
        <FieldOrder>0</FieldOrder>
        <FieldType>Separator</FieldType>
        <Visible>false</Visible>
        <ShowOnEdit>true</ShowOnEdit>
        <Searchable>false</Searchable>
        <PrivateField>false</PrivateField>
        <NormalizeFlag>false</NormalizeFlag>
        <ValidationMessage>Please enter the name of the website associated with your account.</ValidationMessage>
        <ValueColumn>Blue_x0020_Shield</ValueColumn>
        <SortColumn>Blue_x0020_Shield</SortColumn>
      </Fields>
      <Fields>
        <UserDefinedFieldId>81</UserDefinedFieldId>
        <ModuleID>898</ModuleID>
        <FieldTitle>Username (Blue Shield)</FieldTitle>
        <Required>false</Required>
        <FieldOrder>1</FieldOrder>
        <FieldType>String</FieldType>
        <Visible>true</Visible>
        <ShowOnEdit>true</ShowOnEdit>
        <Searchable>false</Searchable>
        <PrivateField>false</PrivateField>
        <NormalizeFlag>false</NormalizeFlag>
        <ValidationMessage>Please type your username for the account.</ValidationMessage>
        <ValueColumn>Username_x0020__x0028_Blue_x0020_Shield_x0029_</ValueColumn>
        <SortColumn>Username_x0020__x0028_Blue_x0020_Shield_x0029_</SortColumn>
      </Fields>
    
    
      <Data>
        <UserDefinedRowId>12</UserDefinedRowId>
        <Blue_x0020_Shield />
        <Username_x0020__x0028_Blue_x0020_Shield_x0029_>Employer UN</Username_x0020__x0028_Blue_x0020_Shield_x0029_>
        <Password_x0020__x0028_Blue_x0020_Shield_x0029_>Employer PW</Password_x0020__x0028_Blue_x0020_Shield_x0029_>
        <Link_x0020__x0028_Blue_x0020_Shield_x0029_>Employer Link</Link_x0020__x0028_Blue_x0020_Shield_x0029_>
        <Aetna />
        <Username_x0020__x0028_Aetna_x0029_>Employer UN</Username_x0020__x0028_Aetna_x0029_>
        <Password_x0020__x0028_Aetna_x0029_>Employer PW</Password_x0020__x0028_Aetna_x0029_>
        <Link_x0020__x0028_Aetna_x0029_>Employer Link</Link_x0020__x0028_Aetna_x0029_>
        <Principal_x0020_Financial_x0020_Dental />
        <Username_x0020__x0028_Principal_x0020_Financial_x0029_ />
        <Password_x0020__x0028_Principal_x0020_Financial_x0029_ />
        <Link_x0020__x0028_Principal_x0020_Financial_x0029_ />
        <My_x0020_Secure_x0020_Advantage />
        <Username_x0020__x0028_My_x0020_Secure_x0020_Advantage_x0029_ />
        <Password_x0020__x0028_My_x0020_Secure_x0020_Advantage_x0029_ />
        <Link_x0020__x0028_My_x0020_Secure_x0020_Advantage_x0029_ />
        <Health_x0020_Butler />
        <Username_x0020__x0028_Health_x0020_Butler_x0029_ />
        <Password_x0020__x0028_Health_x0020_Butler_x0029_ />
        <Link_x0020__x0028_Health_x0020_Butler_x0029_ />
        <FSA />
        <Username_x0020__x0028_FSA_x0029_ />
        <Password_x0020__x0028_FSA_x0029_ />
        <Link_x0020__x0028_FSA_x0029_ />
        <HSA />
        <Username_x0020__x0028_HSA_x0029_ />
        <Password_x0020__x0028_HSA_x0029_ />
        <Link_x0020__x0028_HSA_x0029_ />
        <Created_x0020_by>OSNC Employer</Created_x0020_by>
        <Created_x0020_at>2012-01-13T10:26:53-08:00</Created_x0020_at>
        <Changed_x0020_by>OSNC Employer</Changed_x0020_by>
        <Changed_x0020_at>2012-01-13T10:26:53-08:00</Changed_x0020_at>
      </Context>
    </UserDefinedTable>
    

    XSL代码:

    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:udt="DotNetNuke/UserDefinedTable" exclude-result-prefixes ="udt">
      <xsl:output method="xml" version="1.0"  indent="yes" omit-xml-declaration="yes" />
      <xsl:template match="/udt:UserDefinedTable">
        <xsl:variable name ="imgColumn" select="//udt:Fields[udt:FieldType='Image'][1]/udt:ValueColumn"/>
        <xsl:variable name ="titleColumn" select="//udt:Fields[udt:FieldType='String'][CreatedBy]/udt:ValueColumn"/>
        <xsl:variable name ="htmlColumn" select="//udt:Fields[udt:FieldType='TextHtml'][1]/udt:ValueColumn"/>
        <xsl:variable name ="NameOfCurrentUser"        select ="udt:Context/udt:UserName"/>
        <xsl:variable name ="IsAdministrator"          select ="udt:Context/udt:IsAdministratorRole='true'"/>
        <xsl:variable name ="NameOfCreatedByColumn"    select="concat(udt:Fields[udt:FieldType='CreatedBy']/udt:ValueColumn, '_UDT_Original')"/>
        <xsl:variable name="per-row" select="number(4)" /> 
    
        <!-- Sorting Support-->
        <xsl:variable name="OrderBy">
          <xsl:choose>
            <xsl:when test ="//udt:Fields[udt:UserDefinedFieldId=//udt:Context/udt:OrderBy]/udt:SortColumn">
              <xsl:value-of select ="//udt:Fields[udt:UserDefinedFieldId=//udt:Context/udt:OrderBy]/udt:SortColumn"/>
            </xsl:when>
            <xsl:otherwise>UserDefinedRowId</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:variable name="OrderDirection">
          <xsl:choose>
            <xsl:when test ="//udt:Context/udt:OrderDirection">
              <xsl:value-of select ="//udt:Context/udt:OrderDirection"/>
            </xsl:when>
            <xsl:otherwise>ascending</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:variable name="OrderType">
          <xsl:variable name ="DataType" select ="//udt:Fields[udt:UserDefinedFieldId=//udt:Context/udt:OrderBy]/udt:FieldType"/>
          <xsl:choose>
            <xsl:when test="$DataType='Int32' or $DataType='Decimal' or $DataType='Currency'">number</xsl:when>
            <xsl:otherwise>text</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:if test="udt:Data">
          <table cellspacing="0" cellpadding="4"  border="0"  style="border-width:0px;border-collapse:collapse;">
            <xsl:for-each select="udt:Data[*[name()=$NameOfCreatedByColumn]=$NameOfCurrentUser]">
              <!--Sorting-->
              <xsl:sort select="*[name()=$OrderBy]" order="{$OrderDirection}" data-type= "{$OrderType}"/>
    
              <xsl:variable name="id" select="udt:UserDefinedRowId"/>
              <tr class="Normal">
                <td valign="top">
                  <xsl:if test="udt:EditLink">
                    <a>
                      <xsl:attribute name="href">
                        <xsl:value-of select="udt:EditLink" />
                      </xsl:attribute>
                      <img border="0" alt="edit">
                        <xsl:attribute name="src">
                          <xsl:value-of select="//udt:Context/udt:ApplicationPath"/>/images/edit.gif
                        </xsl:attribute>
                      </img>Edit My Info
                    </a>
                  </xsl:if>
                </td>
                <td>
                  <h2>
                    <xsl:value-of select="udt:Created_x0020_by" disable-output-escaping="yes" />
                  </h2>
                  <xsl:value-of select="//udt:Data[udt:UserDefinedRowId=$id]/*[name()=$htmlColumn]" disable-output-escaping="no"/>
                  <table cellspacing="0" cellpadding="0" border="0">
                    <xsl:for-each select="//udt:Fields[(udt:FieldType!='CreatedBy' and udt:FieldType!='Separator' and udt:Visible='true') 
                                          or (udt:FieldType='CreatedBy' and udt:FieldType!='Separator' and $IsAdministrator)]">
                      <xsl:variable name="NameOfValueColumn" select="udt:ValueColumn"/>
                      <xsl:variable name="CurrentValue" select="//udt:Data[udt:UserDefinedRowId=$id]/*[name()=$NameOfValueColumn]"/>
                      <xsl:if test ="$CurrentValue and $CurrentValue!='' and ($NameOfValueColumn!=$imgColumn or not($imgColumn)) and ($NameOfValueColumn!=$titleColumn  or not($titleColumn)) and ($NameOfValueColumn!=$htmlColumn  or not($htmlColumn)) and (udt:Visible='true' or udt:Visible='True')" >
                        <tr class="Normal">
                        <td><!--<xsl:value-of select ="udt:FieldType=Separator"/>:-->
    
                        </td>
                          <td>
                            <xsl:value-of select ="udt:FieldTitle"/>:
                          </td>
                          <td>&#160;</td>
                          <td>
                            <xsl:value-of select="$CurrentValue" disable-output-escaping="no"/>
                          </td>
                        </tr>
                      </xsl:if>
                    </xsl:for-each>
                    <tr>
                      <td></td>
                      <td></td>
                      <td></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </xsl:for-each>
          </table>
        </xsl:if>
      </xsl:template>
    </xsl:stylesheet>
    

0 个答案:

没有答案