-2

I can't use xPath to query my xml file. I don't know where the error is and this is my schema

<?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>

this is my xml file after use marshall to generate the xml file

<?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>

and this is my xsl file

<?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>

in the jsp file when run the webpage, I can't get the result what I want. xsl file can't read the xml file with the xpath query

VuongNQ
  • 43
  • 1
  • 6

1 Answers1

0

You have to register the namespace. Have a look to: php manual

hr_117
  • 9,589
  • 1
  • 18
  • 23
  • how can I register the namespace? please tell me and I cant read php code – VuongNQ Jun 23 '13 at 09:08
  • What language do you use to execute the xpath? I assumed php because of the tag **domxpath** (which is a PAP API.) – hr_117 Jun 23 '13 at 10:42
  • thanks for your help I have solve it by myself. I forgot the namespace in the xpath query after searching, the problem was solve – VuongNQ Jun 23 '13 at 10:59