Multi layer conditional wrap HTML with XSLT

前端 未结 1 1639
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-26 01:46

In my Umbraco CMS site, I\'m making a list of node \"widgets\" for content editors to use, with a list of many options they can toggle to change the display. This often involves

相关标签:
1条回答
  • 2021-01-26 02:30
     <!--Store data in processing instruction nodes in a separate XML file-->
     <?xml version='1.0' encoding="utf-8"?>
     <root>
       <?_1 div?>
       <?_2 p?>
     </root>
    

    type_1 is wrapped by certain tags, type_2 is wrapped by different tags.

     <xsl:variable name="divider" select="document('condition.xml')//processing-instruction(concat('_', $type) )" />
     <xsl:variable name="equalizer" select="'span'"/>
     <xsl:element name="{$divider}">
     ...
     </xsl:element>
    

    Next layer in, both could be wrapped by the same tags

     <xsl:if test="contains('1,2',$type)">
       <xsl:element name="{$equalizer}">
       ...
       </xsl:element>
     </xsl:if>
    
    0 讨论(0)
提交回复
热议问题