XSLTを使用して入力xmlを変換する必要があります。 それは、CDATAを含んでいます。私はCDATAから要素を抽出する必要があり、タグの名前を変更する必要があります。以下は XSLT変換とCDATA
は私の入力xmlです:<getArtifactContentResponse>
<return>
<![CDATA[
<metadata>
<overview>
<name>scannapp</name>
<developerId>developer702</developerId>
<stateId>2</stateId>
<serverURL>dddd</serverURL>
<id>cspapp1103</id>
<description>scann doc</description>
<hostingTypeId>1</hostingTypeId>
</overview>
</metadata>
]]>
</return>
</getArtifactContentResponse>
と予想される出力は次のようになります。私が使用しています
<?xml version="1.0" encoding="UTF-8"?>
<metadata >
<information>
<name>scannapp</name>
<developerId>developer702</developerId>
<stateId>2</stateId>
<serverURL>ddddd</serverURL>
<id>cspapp1103</id>
<description>scann doc</description>
<hostingTypeId>1</hostingTypeId>
</Information>
</metadata>
XSLTは以下の通りです:これにより
<xsl:output method="xml" version="1.0" encoding="UTF-8" />
<xsl:template match="/">
<xsl:value-of select="//ns:getArtifactContentResponse/ns:return/text()" disable-output-escaping="yes"/>
</xsl:template>
<xsl:template match="overview">
<Information>
<xsl:apply-templates select="@* | node()" />
</Information>
</xsl:template>
私はexrtactすることができるCDATAは、 '概要'の要素の名前を '情報'に変更していません。
変換されたXMLは以下の通りです:
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<overview>
<name>scannapp</name>
<developerId>developer702</developerId>
<stateId>2</stateId>
<serverURL>dddddd</serverURL>
<id>cspapp1103</id>
<description>scann doc</description>
<hostingTypeId>1</hostingTypeId>
</overview>
</metadata>
誰かが私はCDATAを抽出した後、タグの名前を変更する方法を教えてもらえますか? 私はここに何が欠けているのか分かりません。アドバンス
XSLTバージョン1.0しか使用できない場合は、最初のXSLTの出力で別のXSLTを実行して、目的の出力を生成する必要があります。 CDataの内容はプレーンテキストと見なされるため、XSLTでは通常のXMLフラグメントと同様に処理することはできません。 – har07
関連1. [コンテンツがCDATAの中にあるxml要素を変換する](http://stackoverflow.com/questions/2067116/convert-an-xml-element-whose-content-is-inside-cdata)、2。 [XSLを使用してCDATAからXMLを変換する](http://stackoverflow.com/questions/18612639/transform-xml-from-cdata-using-xsl) – har07
私には分かりません。上記の例で説明していただけますか? – krishh