-2
我無法使用xPath來查詢我的xml文件。我不知道哪裏出錯 ,這是我的架構無法查詢從編組自動生成的xml文件
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.netbeans.org/schema/Manufacturers"
xmlns="http://xml.netbeans.org/schema/Manufacturers"
elementFormDefault="qualified">
<xsd:element name="ManufacturerList">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Manufacturer" type="manufacturerType" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="manufacturerType">
<xsd:sequence>
<xsd:element name="ManufacturersID" type="xsd:positiveInteger"/>
<xsd:element name="ManufacturersName" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
這是使用後馬歇爾我的XML文件來生成XML文件
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ManufacturerList xmlns="http://xml.netbeans.org/schema/Manufacturers">
<Manufacturer>
<ManufacturersID>1</ManufacturersID>
<ManufacturersName>SamSung</ManufacturersName>
</Manufacturer>
<Manufacturer>
<ManufacturersID>2</ManufacturersID>
<ManufacturersName>Apple</ManufacturersName>
</Manufacturer>
<Manufacturer>
<ManufacturersID>3</ManufacturersID>
<ManufacturersName>Nokia</ManufacturersName>
</Manufacturer>
這是我的xsl文件
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:manu="http://xml.netbeans.org/schema/Manufacturers"
exclude-result-prefixes="manu" version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="/">
<xsl:for-each select="/manu:Manufacturer">
<li>
<a href="#">
<xsl:value-of select="manu:ManufacturersName"/>
</a>
</li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
在jsp文件運行網頁時,我無法得到我想要的結果。 XSL文件無法讀取與XPath查詢
我該如何註冊命名空間? 請告訴我 ,我不能讀取php代碼 – VuongNQ
你用什麼語言來執行xpath?我假設PHP是因爲標籤** domxpath **(這是一個PAP API。) –
感謝您的幫助 我已經自己解決了。我在搜索後忘記了xpath查詢 中的命名空間,問題就解決了 – VuongNQ