そこで、php curl 応答から生成した XML ファイルを取得しました。このファイルは、以下の各 mods 要素が 1 行になるように CSV に変換されます。チェック済みの回答hereのスタイルシートを使用して CSV をいくつか持っていますが、それは私がやろうとしていることではありません。
私のXML(簡略化):
<xml>
<mods xmlns="http://www.loc.gov/mods/">
<typeOfResource>StillImage</typeOfResource>
<titleInfo ID="T-1">
<title>East Bay Street</title>
</titleInfo>
<subject ID="SBJ-2">
<topic>Railroads</topic>
</subject>
<subject ID="SBJ-3">
<geographic>Low Country</geographic>
</subject>
<subject ID="SBJ-4">
<geographic>Charleston (S.C.)</geographic>
</subject>
<subject ID="SBJ-7">
<hierarchicalGeographic>
<county>Charleston County (S.C.)</county>
</hierarchicalGeographic>
</subject>
<physicalDescription>
<form>Images</form>
</physicalDescription>
<note>Caption: 'War Views. No.179. Ruins of the Northeastern Railway Depot, Charleston.' This is a stereograph image which measures 3 1/2" X 7". Date assumed to be 1865.</note>
<originInfo>
<dateCreated>1865</dateCreated>
</originInfo>
<location>
<physicalLocation>The Charleston Museum Archives</physicalLocation>
</location>
<relatedItem type="host">
<titleInfo>
<title>Charleston Museum Civil War Photographs</title>
</titleInfo>
</relatedItem>
</mods>
<mods>
more nodes...
</mods>
</xml>
上記のスタック投稿からの現在の XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="iso-8859-1"/>
<xsl:strip-space elements="*" />
<xsl:template match="/*/child::*">
<xsl:for-each select="child::*">
<xsl:if test="position() != last()"><xsl:value-of select="normalize-space(.)"/>, </xsl:if>
<xsl:if test="position() = last()"><xsl:value-of select="normalize-space(.)"/> <xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
これにより、各 MODS 要素が 1 行であり、各子がその行のコンマ区切りの値である CSV が出力されます。各 MODS 要素が 1 行になるように XSL を変更できますが、一致する子の値はグループ化されますか? 何かのようなもの:
StillImage,East Bay Street,Railroads,**Low County;Charleston (S.C.)**,Charleston County (S.C.), Images
.......等々。
ノード (複数のサブジェクト -> 地理的エントリなど) が一致する場合、それらはグループ化され、複数のカンマ区切りの値を使用するのではなく、セミコロンで区切られますか? うまくいけば、私はいくつかの意味を成しています。ありがとう!