我正在尝试访问使用命名空间的 .xml 文件中的节点并对其进行排序。它不起作用,我认为它与命名空间有关,无法正确限定它们。
我有一个 index.xml,我用它来组合我需要的文档,看起来像这样:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="merge.xsl"?>
<pic:catalog xmlns:pic = "pictureCatalog">
<pic:logo>Logo</pic:logo>
<Author>User Name</Author>
<pic:allPhotos>photos</pic:allPhotos>
</pic:catalog>
照片.xml 看起来像这样:
<?xml version="1.0"?>
<pic:photoCatalog xmlns:pic="pictureCatalog">
<pic:photo>
<pic:title>Alcazar</pic:title>
<pic:location>Segovia - Spain</pic:location>
<pic:date>Jan 2013</pic:date>
<pic:camera>Sony</pic:camera>
<pic:resolution>12px</pic:resolution>
<pic:format>.jpg</pic:format>
<pic:description>
Medieval Castle over the hill overlooking the city.
</pic:description>
</pic:photo>
</pic:photoCatalog>
我的 xsl 样式表如下所示:
<!-- All the photos-->
<xsl:template match = "pic:catalog/pic:allPhotos">
<html>
<head>
<link rel="stylesheet" type="text/css" href="Style.css" />
</head>
<body>
<xsl:for-each select="pic:photoCatalog/pic:photo"><br/>
<xsl:sort select="pic:location"/>
<xsl:value-of select="pic:photoCatalog/pic:photo/pic:location"/>
</xsl:for-each>
</body>
</html>
</xsl:template>
任何人都可以帮忙吗?
蓝牙