我有一个输入XML如下所示。将多个属性连接成一个XSL
<?xml version="1.0" encoding="UTF-8"?>
<topic title="My Topic" subtopic="My SubTopic">
<table title="My Table" media="print" role="center">
<thead></thead>
<tbody></tbody>
</table>
</topic>
我希望它能与XSL一起翻译如下。
<?xml version="1.0" encoding="UTF-8"?>
<topic title="My Topic" subtitle="My Subtopic">
<table title="My Table" outputclass="print center">
<thead></thead>
<tbody></tbody>
</table>
</topic>
如果您发现表中的任何其他属性必须命名为OutputClass类一个属性进行串接,但不表的唯一的其他属性的话题。
我有一个这样的XSL -
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl xsi">
<xsl:output method="xml" indent="yes" omit-xml-declaration="no"
standalone="no" doctype-public="-//OASIS//DTD DITA Composite//EN" doctype-system="topic.dtd"/>
<!-- Generic element -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="table">
<table>
<xsl:apply-templates select="@role | @media" mode="table.att"/>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="@*">
<xsl:if test="local-name(.)!='noNamespaceSchemaLocation'">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:if>
</xsl:template>
<xsl:template match="@*" mode="table.att">
<xsl:choose>
<xsl:when test="local-name() = 'role'">
<xsl:attribute name="outputclass">
<xsl:value-of select="."></xsl:value-of>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<!-- <xsl:apply-templates select="."/> -->
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
正如预期的那样,它不会做的伎俩。你能帮我解决这个问题吗? 我想我需要将所有属性一起发送以连接它,但我不知道如何做到这一点。