0
入力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>
あなたがテーブルの他の属性に気づいた場合は1つの 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>
予想したように、それはトリックを行いませんが。あなたはこれで私を助けてくれますか? 私はそれを連結するためにすべての属性を一緒に送る必要があると思いますが、私はそれをどうやって行うのか分かりません。