次のような XML ファイルがあります。
<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type="text/xsl" href="http://url/stylesheet.xsl"?>
<first xmlns="http://www.loc.gov/zing/srw/">
<element1>And</element1>
<e2>I said</e2>
<e3>
<e4>
<mods version="3.0"
xmlns:bla="http://www.w3.org/1999/xlink"
xmlns:bla2="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.loc.gov/mods/v3"
xsi:schemaLocation="http://www.loc.gov/mods/v3">
<f1>What about</f1>
<f2>Breakfast at Tiffany's</f2>
</mods>
</e4>
</e3>
</first>
一方、XPath 経由で要素を取得するための XSL ファイルがあります。
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:n="http://www.loc.gov/zing/srw/"
xmlns:o="http://www.loc.gov/mods/v3">
<xsl:template match="/">
<html><head></head><body>
<xsl:value-of select="n:first/n:e2"/>
</body></html>
</xsl:template>
</xsl:stylesheet>
これで、私が言った要素 e2 を取得でき ますが、ティファニーで朝食を言う要素 f4 にアクセスするのに問題があります 。XPath は、要素 f4 に 2 つの名前空間があると想定していますか (デフォルトの名前空間 xmlns="http://www.loc.gov/zing/srw/" が最初にルート要素で宣言され、要素mods xmlns="http: //www.loc.gov/mods/v3") または mods 名前空間 xmlns="http://www.loc.gov/mods/v3" は mods 要素のすべての子要素の唯一の名前空間ですか? また、xsl ファイルで接頭辞を宣言しなくても、実際に要素 e2 に簡単にアクセスできますか? XML/XSL を使い始めたばかりなので、質問が明確であることを願っています。