0

I have the following XML.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="invoice.xsl"?>
<!DOCTYPE invoice [
    <!ELEMENT invoice (company, to:customer, order)>
    <!ATTLIST invoice xmlns:to CDATA #FIXED "http://www.companyltd.co.nz/dtds/">

    <!ELEMENT company (name, address, city, phone, email)>
        <!ELEMENT name (#PCDATA)>
        <!ELEMENT address (#PCDATA)>
        <!ELEMENT city (#PCDATA)>
        <!ELEMENT phone (#PCDATA)>
        <!ELEMENT email (#PCDATA)>

    <!ELEMENT to:customer (to:name, to:address, to:city, to:phone, to:email)>
        <!ELEMENT to:name (#PCDATA)>
        <!ELEMENT to:address (#PCDATA)>
        <!ELEMENT to:city (#PCDATA)>
        <!ELEMENT to:phone (#PCDATA)>
        <!ELEMENT to:email (#PCDATA)>

    <!ELEMENT order (item+)>
        <!ELEMENT item (id, description, qty, unit-price, total)>
            <!ELEMENT id (#PCDATA)>
            <!ELEMENT description (#PCDATA)>
            <!ELEMENT qty (#PCDATA)>
            <!ELEMENT unit-price (#PCDATA)>
            <!ELEMENT total (#PCDATA)>
]>
<invoice xmlns:to="http://www.companyltd.co.nz/dtds/">
    <company>
        <name>Company Ltd</name>
        <address>111 Placeholder Street</address>
        <city>Hamilton</city>
        <phone>078433411</phone>
        <email>sales@companyltd.co.nz</email>
    </company>

    <to:customer>
        <to:name>Duncan Palmer</to:name>
        <to:address>111 Reee Street</to:address>
        <to:city>Lofton</to:city>
        <to:phone>8133333</to:phone>
        <to:email>duncanrp15@live.com</to:email>
    </to:customer>

    <order>
        <item>
            <id>1</id>
            <description>Black Socks</description>
            <qty>5</qty>
            <unit-price>5</unit-price>
            <total>25</total>
        </item>
    </order>
</invoice>

I am trying to transform the to:customer elements to my xsl page. I have tried using this..

<xsl:value-of select="//to:customer//to:name"/>

However this just throws an 'Error loading stylesheet: An unknown error has occurred ()' Error.

What is the correct way to reference XML that is using a namespace in XSL?

Duncan Palmer
  • 2,865
  • 11
  • 63
  • 91

0 Answers0