私は XML/XSLT にまったく精通していません。私は、この XML ファイルを自分の Access データベースで使用できるものに変換するのに十分なだけ学習しようとしています。XML データは属性形式で出力され、Access は要素形式のみを好みます。基本的な変換は完了しましたが、ネストされたデータを要素化できないようです。
最終結果をすべての要素にしたいと思います。現時点では、私の XSLT スクリプトは子要素の名前に親の名前属性を含めようとしていますが、それは必要ないかもしれません。リストの要素に番号を付けて名前を付けることができれば最高です。「AuthorList1」、「AuthorList2」または「Author1」、「Author2」など。
私が扱っているXMLの種類は次のとおりです(省略):
XML
<Result>
<DocSum>
<Id>25587056</Id>
<Item Name="PubDate" Type="Date">2015 Jan 13</Item>
<Item Name="EPubDate" Type="Date">2015 Jan 13</Item>
<Item Name="Source" Type="String">Invest Ophthalmol Vis Sci</Item>
<Item Name="AuthorList" Type="List">
<Item Name="Author" Type="String">Wang Q</Item>
<Item Name="Author" Type="String">Tuten WS</Item>
<Item Name="Author" Type="String">Lujan BJ</Item>
</Item>
<Item Name="Title" Type="String">Adaptive optics microperimetry</Item>
<Item Name="Volume" Type="String">56</Item>
<Item Name="ArticleIds" Type="List">
<Item Name="pubmed" Type="String">25587056</Item>
<Item Name="pii" Type="String">iovs.14-15576</Item>
<Item Name="doi" Type="String">10.1167/iovs.14-15576</Item>
</Item>
<Item Name="References" Type="List"></Item>
<Item Name="HasAbstract" Type="Integer">1</Item>
</DocSum>
</Result
私は XSLT についてかなり理解を深めてきましたが、まだそこまで到達したわけではありません。発生し続ける問題の 1 つは、空の要素 (参照など) が許可されていない null 名を取得することです。これは、"Item[@Type='List']" の一致パターンを使用してコマンドを実行しようとしたときに発生しました。また、リストの子ノード (要素?) を独自の要素にすることができないようです。
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*" >
<xsl:element name="{name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Item">
<xsl:element name="{@Name}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="child::Item">
<xsl:variable name="Parent" select="TEST"/>
<xsl:element name="{$Parent}{@Name}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
これが何らかの意味をなすことを願っています。XML 変換を再び扱うことになるとは思えないので、この分野の専門家になるつもりはまったくありません。今後のヘルプがあれば幸いです。