【问题标题】:While transforming xml to html using xsl and java, I need to use style attribute(inline style) with xml element value在使用 xsl 和 java 将 xml 转换为 html 时,我需要使用带有 xml 元素值的样式属性(内联样式)
【发布时间】:2016-04-02 09:08:42
【问题描述】:

我有以下要求。我需要 XMl 元素用于 xslt 表格内联样式。请检查以下代码。

XML 伪代码:

这是包含以下数据的xml代码

            <xml>
            <event>
            <message>
            This is message
            </message>
            <color>
            #66666
            </color>
            </event>

XSLT 代码:

            <?xml version="1.0" encoding="UTF-8"?>
            <xsl:stylesheet version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

            <xsl:template match="/">
              <html>
              <body>
              <h2>My CD Collection</h2>
              <table border="1">
                <tr bgcolor="#<xsl:value-of select='/event/color'/>">//something in this way i need use

                </tr>
                <tr>
                  <td><xsl:value-of select="/event/message"/></td>

                </tr>
              </table>
              </body>
              </html>
            </xsl:template>

            </xsl:stylesheet>

所以我需要使用内联样式作为 xml 元素。 有什么解决方案,并建议我在哪里可以使用 xml 和 java 学习 xslt

以类似的方式,我需要在其中添加 css 文件,我还需要使用颜色值的这个 xml 元素

【问题讨论】:

  • 这是消息#666666xml是这样的

标签: java xml xslt


【解决方案1】:

您可以使用属性值模板&lt;tr bgcolor="{event/color}"&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-06
    • 2011-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多