I'm unable to find any matches for the following XPath (reference schema
and instance documents listed below): 

/MASTER_RECORD/DETAIL_RECORD/ACCOUNT_NUMBER 

query expression: $this/MASTER_RECORD/DETAIL_RECORD/ACCOUNT_NUMBER   

I tried a number of different namespace declarations with the above
expression, but none worked.  Additionally, I tried a number of
XmlOptions such as follows: 

            XmlOptions Xoptions= new XmlOptions(); 
            Map map = new HashMap(); 
            map.put("prep", ""); 
 
map.put("http://order.rd.com/Namespaces/Types/Public/prep.xsd";, null); 
            Xoptions.setLoadAdditionalNamespaces(map); 

XmlBeans apparently has created a default prefix of 'prep'.  I'm not
sure why?  If I change my original XPath to 

/prep:MASTER_RECORD/prep:DETAIL_RECORD/prep:ACCOUNT_NUMBER 

and change the query expression for the selectPath as follows: 

declare namespace
prep='http://order.rd.com/Namespaces/Types/Public/prep.xsd';$this/prep:M
ASTER_RECORD/prep:DETAIL_RECORD/prep:ACCOUNT_NUMBER
<http://order.rd.com/Namespaces/Types/Public/prep.xsd%27;$this/prep:MAST
ER_RECORD/prep:DETAIL_RECORD/prep:ACCOUNT_NUMBER>  

Then the XPath is resolved.  The input XML document does not include the
'prep' prefix.  So how can I avoid using the 'prep' prefix in my XPath
and how would I declare my namespace? 

Reference XSDs: 

prep.xsd: 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<xs:schema
targetNamespace="http://order.rd.com/Namespaces/Types/Public/prep.xsd";
xmlns="http://order.rd.com/Namespaces/Types/Public/prep.xsd";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:tlg="http://order.rd.com/Namespaces/Types/Public/tlg.xsd";
elementFormDefault="qualified" version="v001"> 
        <xs:import
namespace="http://order.rd.com/Namespaces/Types/Public/tlg.xsd";
schemaLocation="tlg.xsd"/> 
        <xs:element name="MASTER_RECORD"> 
                <xs:annotation> 
                        <xs:documentation>Root
Element</xs:documentation> 
                </xs:annotation> 
                <xs:complexType> 
                        <xs:sequence> 
                                <xs:element name="DETAIL_RECORD"> 
                                        <xs:complexType> 
                                                <xs:sequence> 
                                                        <xs:element
name="ACCOUNT_NUMBER" type="TAccountNumber"/> 
 
<xs:element name="ACCOUNT_DETAIL" type="tlg:ACCOUNT"> 
 
<xs:annotation> 
 
<xs:documentation>Root of tlg ACCOUNT</xs:documentation> 
 
</xs:annotation> 
 
</xs:element> 
                                                </xs:sequence> 
                                        </xs:complexType> 
                                </xs:element> 
                        </xs:sequence> 
                </xs:complexType> 
        </xs:element> 
        <xs:simpleType name="TAccountNumber"> 
                <xs:restriction base="xs:string"> 
                        <xs:maxLength value="16"/> 
                        <xs:minLength value="5"/> 
                </xs:restriction> 
        </xs:simpleType> 
</xs:schema> 

tlg.xsd: 

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<xs:schema xmlns="http://order.rd.com/Namespaces/Types/Public/tlg.xsd";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
targetNamespace="http://order.rd.com/Namespaces/Types/Public/tlg.xsd";
elementFormDefault="unqualified" attributeFormDefault="unqualified"
version="1.1.00"> 
        <xs:complexType name="ACCOUNT"> 
                <xs:sequence> 
                                <xs:element ref="PURCHASE_ORD_NO"
minOccurs="0"/> 
                                <xs:element ref="INVOICE_NO"
minOccurs="0"/> 
                </xs:sequence> 
        </xs:complexType> 
        <xs:element name="PURCHASE_ORD_NO"> 
                <xs:complexType mixed="true"> 
                        <xs:choice minOccurs="0" maxOccurs="unbounded"/>

                </xs:complexType> 
        </xs:element> 
        <xs:element name="INVOICE_NO"> 
                <xs:complexType mixed="true"> 
                        <xs:choice minOccurs="0" maxOccurs="unbounded"/>

                </xs:complexType> 
        </xs:element> 
</xs:schema> 

Reference XML: 

<?xml version="1.0" encoding="UTF-8"?> 
<MASTER_RECORD
xmlns="http://order.rd.com/Namespaces/Types/Public/prep.xsd";
xmlns:tlg="http://order.rd.com/Namespaces/Types/Public/tlg.xsd";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> 
        <DETAIL_RECORD> 
                <ACCOUNT_NUMBER>String</ACCOUNT_NUMBER> 
                <ACCOUNT_DETAIL> 
                        <tlg:PURCHASE_ORD_NO>Text</tlg:PURCHASE_ORD_NO> 
                        <tlg:INVOICE_NO>Text</tlg:INVOICE_NO> 
                </ACCOUNT_DETAIL> 
        </DETAIL_RECORD> 
</MASTER_RECORD> 

Thanks. 

Reply via email to