どうやっていけばいいですか?属性値がXSLT未知の名前空間?
-
09-06-2019 - |
質問
を得ていますが、第3者の送り難しい問題になるかもしれないときは、特定の名前空間で、現在私有地元の名機の私のXSLTの要素の値です。がりさん属性からな要素がわからないの際に利用することがでの名前空間は不明によって地域名()機能)。
N.B.を使用しています。純2.0にXSLT
こちらのログインidとパスワードのXML:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>some id</id>
<title>some title</title>
<updated>2008-09-11T15:53:31+01:00</updated>
<link rel="self" href="http://www.somefeedurl.co.uk" />
<author>
<name>some author</name>
<uri>http://someuri.co.uk</uri>
</author>
<generator uri="http://aardvarkmedia.co.uk/">AardvarkMedia script</generator>
<entry>
<id>http://soemaddress.co.uk/branded3/80406</id>
<title type="html">My Ttile</title>
<link rel="alternate" href="http://www.someurl.co.uk" />
<updated>2008-02-13T00:00:00+01:00</updated>
<published>2002-09-11T14:16:20+01:00</published>
<category term="mycategorytext" label="restaurant">Test</category>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<div class="vcard">
<p class="fn org">some title</p>
<p class="adr">
<abbr class="type" title="POSTAL" />
<span class="street-address">54 Some Street</span>
,
<span class="locality" />
,
<span class="country-name">UK</span>
</p>
<p class="tel">
<span class="value">0123456789</span>
</p>
<div class="geo">
<span class="latitude">51.99999</span>
,
<span class="longitude">-0.123456</span>
</div>
<p class="note">
<span class="type">Review</span>
<span class="value">Some content</span>
</p>
<p class="note">
<span class="type">Overall rating</span>
<span class="value">8</span>
</p>
</div>
</div>
</content>
<category term="cuisine-54" label="Spanish" />
<Point xmlns="http://www.w3.org/2003/01/geo/wgs84_pos#">
<lat>51.123456789</lat>
<long>-0.11111111</long>
</Point>
</entry>
</feed>
これは、XSLT
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:wgs="http://www.w3.org/2003/01/geo/wgs84_pos#" exclude-result-prefixes="atom wgs">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="uniqueVenuesKey" match="entry" use="id"/>
<xsl:key name="uniqueCategoriesKey" match="entry" use="category/@term"/>
<xsl:template match="/">
<locations>
<!-- Get all unique venues -->
<xsl:for-each select="/*[local-name()='feed']/*[local-name()='entry']">
<xsl:variable name="CurrentVenueKey" select="*[local-name()='id']" ></xsl:variable>
<xsl:variable name="CurrentVenueName" select="*[local-name()='title']" ></xsl:variable>
<xsl:variable name="CurrentVenueAddress1" select="*[local-name()='content']/*[local-name()='div']/*[local-name()='div']/*[local-name()='p'][@class='adr']/*[local-name()='span'][@class='street-address']" ></xsl:variable>
<xsl:variable name="CurrentVenueCity" select="*[local-name()='content']/*[local-name()='div']/*[local-name()='div']/*[local-name()='p'][@class='adr']/*[local-name()='span'][@class='locality']" ></xsl:variable>
<xsl:variable name="CurrentVenuePostcode" select="*[local-name()='postcode']" ></xsl:variable>
<xsl:variable name="CurrentVenueTelephone" select="*[local-name()='telephone']" ></xsl:variable>
<xsl:variable name="CurrentVenueLat" select="*[local-name()='Point']/*[local-name()='lat']" ></xsl:variable>
<xsl:variable name="CurrentVenueLong" select="*[local-name()='Point']/*[local-name()='long']" ></xsl:variable>
<xsl:variable name="CurrentCategory" select="WHATDOIPUTHERE"></xsl:variable>
<location>
<locationName>
<xsl:value-of select = "$CurrentVenueName" />
</locationName>
<category>
<xsl:value-of select = "$CurrentCategory" />
</category>
<description>
<xsl:value-of select = "$CurrentVenueName" />
</description>
<venueAddress>
<streetName>
<xsl:value-of select = "$CurrentVenueAddress1" />
</streetName>
<town>
<xsl:value-of select = "$CurrentVenueCity" />
</town>
<postcode>
<xsl:value-of select = "$CurrentVenuePostcode" />
</postcode>
<wgs84_latitude>
<xsl:value-of select = "$CurrentVenueLat" />
</wgs84_latitude>
<wgs84_longitude>
<xsl:value-of select = "$CurrentVenueLong" />
</wgs84_longitude>
</venueAddress>
<venuePhone>
<phonenumber>
<xsl:value-of select = "$CurrentVenueTelephone" />
</phonenumber>
</venuePhone>
</location>
</xsl:for-each>
</locations>
</xsl:template>
</xsl:stylesheet>
ようにしているの$CurrentCategory変数を適切なコードを表示 mycategorytext
解決
いXSLTの編集がごしてみました
*[local-name()='category']/@*[local-name()='term']
他のヒント
による http://www.w3.org/TR/2006/REC-xml-names-20060816/#scoping-defaulting
"デフォルト名前空間宣言は適用されない直接属性の名前の解釈の接頭辞を持たない属性を決める要素がかかります。"
この属性がない、名前空間.使おう"@"の".
する目的でクッキーが使用されてビットをより明確にし、必要がない地域名()この問題を解決する.従来の方法に対すことを宣言する接頭辞の原子の名前空間におXSLT、その利用おxpathます。
またこの宣言におスタイルシートの要素("xmlns:原子="http://www.w3.org/2005/Atom"用していただくことができるのですが、利用します。
先程述べたように、既に、その属性の影響を受けないデフォルトの名前空間で、コードのようになります(このための追加"xmlns:xhtml='http://www.w3.org/1999/xhtml'"):
<xsl:for-each select="/atom:feed/atom:entry">
<xsl:variable name="CurrentVenueKey" select="atom:id" />
<xsl:variable name="CurrentVenueName" select="atom:title" />
<xsl:variable name="CurrentVenueAddress1"
select="atom:content/xhtml:div/xhtml:div/xhtml:p[@class='adr']/xhtml:span[@class='street-address']" />
<xsl:variable name="CurrentVenueCity"
select="atom:content/xhtml:div/xhtml:div'/xhtml:p[@class='adr']/xhtml:span[@class='locality'] />
...
<xsl:variable name="CurrentCategory" select="atom:category/@term" />
.....
地域名()を確認することに非常に役立つ場合も非常に良いのではないかと思い構造をXMLで変化しながら、この場合がございます以外のものはいかが?見込んでしまう。
んだい地域名()があれば、これは少し詳細情報どのようなxsltプロセッサーをご利用の言語ができるね。いこのb/cうことができないようなもの:
<xsl:stylesheet xmlns="http://www.w3.org/2005/Atom" ..>
<xsl:template match="feed">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="entry">
...
<xsl:variable name="current-category" select="category/@term" />
...
</xsl:template>
の二つのことを今だにxmlns宣言のない接頭辞です。を設定するデフォルト名前空間はありませんの名前空間接頭辞.同様に、きdo"xmlns:a="http://www.w3.org/2005/Atom"'およびその'select="a:feed"'.その他のものへの通知を使用して'@期"を選択します。したい場合は、試合のあらゆる属性'@*'と同じように動作いためです。
再度、プロセッサがある場合がありますその他の役立つツールで処理でき提供をもう少し情報である。また、 XSLメーリングリスト が別のも資源です。