【问题标题】:Get attributes of a parent node XSLT获取父节点 XSLT 的属性
【发布时间】:2021-10-21 06:50:30
【问题描述】:

我想有条件地格式化 Apache FOP 中的 URL,为此,我想检查 property 是否属于 HYPERLINK 类型,然后应用条件格式并将其转换为 URL。

下面是我的 XML

<properties>
    <property type="CUSTOM" id="150" key="localizedfield">
        <name>Localized Text</name>
        <value>Test</value>
    </property>
    <property type="CUSTOM" id="149" key="textareafield">
        <name>Textarea</name>
        <value>My longer default text.</value>
    </property>
    <property type="HYPERLINK" key="ASSET_LINK">
        <name>Asset Link</name>
        <value>Test=https://test.com</value>
    </property>
    <property type="CUSTOM" key="VALIDITY">
        <name>Asset Availability</name>
        <value>Available</value>
    </property>
</properties>

我用于转换的 XSL 如下所示

<xsl:template name="table-row">
    <xsl:for-each select="properties/property">
        <xsl:apply-templates select="."/>
    </xsl:for-each>
</xsl:template>

<xsl:template match="property">
    <fo:table-cell >
        <fo:block >
            <xsl:choose>
                <xsl:when test="<check if type is HYPERLINK>">
                    <!-- Format as hyperlink -->
                </xsl:when>
                <xsl:otherwise>
                    <!-- format as normal text -->
                </xsl:otherwise>
            </xsl:choose>
        </fo:block>
    </fo:table-cell>
</xsl:template>

在xsl:when 条件下,我只得到name 和value,我怎样才能在这里获得完整的property 节点,以便检查类型属性是否为HYPERLINK,然后进行相应的格式化?

【问题讨论】:

    标签: xslt apache-fop


    【解决方案1】:

    我想你想要

    <xsl:when test="@type='HYPERLINK'">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-19
      相关资源
      最近更新 更多