Namespace prefix used but not declared

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rakeshvthu
    New Member
    • May 2007
    • 27

    Namespace prefix used but not declared

    Hi All,

    I am trying to parse the xml.

    <ns1:ProcessGLA ccountValidatio nRequestABM xmlns:ns1="http ://xmins.oracle.co m/ApplicationObje cts/Ebiz/Core/ABM/ChartOfAccounts/V1">
    <ns2:ChartOfAcc ountsName xmlns:ns2="http ://xmlns.oracle.co m/ApplicationObje cts/Ebiz/Core/ABO/ChartOfAccounts/V1">Netherlan ds Accounting Flex</ns2:ChartOfAcco untsName>
    <ns2:ChartOfAcc ountsId>50560</ns2:ChartOfAcco untsId>
    <ns2:CodeCombin ations>
    <ns2:CodeCombin ationId>76589</ns2:CodeCombina tionId>
    <ns2:GLElementV alueList>
    <ns2:ValueSetNa me>SEGMENT1</ns2:ValueSetNam e>
    <ns2:Value>04 </ns2:Value>
    </ns2:GLElementVa lueList>
    <ns2:GLElementV alueList>
    <ns2:ValueSetNa me>SEGMENT2</ns2:ValueSetNam e>
    <ns2:Value>7410 </ns2:Value>
    </ns2:GLElementVa lueList>
    <ns2:GLElementV alueList>
    <ns2:ValueSetNa me>SEGMENT3</ns2:ValueSetNam e>
    <ns2:Value>32 0</ns2:Value>
    </ns2:GLElementVa lueList>
    <ns2:GLElementV alueList>
    <ns2:ValueSetNa me>SEGMENT4</ns2:ValueSetNam e>
    <ns2:Value>00 0</ns2:Value>
    </ns2:GLElementVa lueList>
    </ns2:CodeCombina tions>
    </ns1:ProcessGLAc countValidation RequestABM>

    but when i tried it is throwing error,

    Exception occured in ValidateCCIDPro cess.process() :oracle.xml.par ser.v2.XMLParse Exception: Namespace prefix 'ns2' used but not declared.
    oracle.xml.pars er.v2.XMLParseE xception: Namespace prefix 'ns2' used but not declared.

    Please help me.
    --------------------

    thanks & regards,
    Rakesh.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Hi,

    all namespaces must be declared in the root element.

    regards

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      I agree, move the namespace declaration to the root.

      More detailed explanation:
      The namespace doesn't have to be declared in the root node; however, each namespace declaration is only good for the element it is in, and all descendants of that node.

      [code=xml]
      <ns2:ChartOfAcc ountsName xmlns:ns2="http ://xmlns.oracle.co m/ApplicationObje cts/Ebiz/Core/ABO/ChartOfAccounts/V1">Netherlan ds Accounting Flex</ns2:ChartOfAcco untsName>
      <ns2:ChartOfAcc ountsId>50560</ns2:ChartOfAcco untsId>
      [/code]
      The ns2 namespace only lasts within the ns2:ChartOfAcco untsName here.
      ns2:ChartOfAcco untsId can not find this namespace in any of its ancestors (parent node, or parent's parent, etc..)

      You could also make the xml valid by redeclaring the namespace wherever you need to, as below, but that gets messy quickly.
      [code=xml]
      <ns2:ChartOfAcc ountsName xmlns:ns2="http ://xmlns.oracle.co m/ApplicationObje cts/Ebiz/Core/ABO/ChartOfAccounts/V1">Netherlan ds Accounting Flex</ns2:ChartOfAcco untsName>
      <ns2:ChartOfAcc ountsId xmlns:ns2="http ://xmlns.oracle.co m/ApplicationObje cts/Ebiz/Core/ABO/ChartOfAccounts/V1">50560</ns2:ChartOfAcco untsId>
      [/code]

      Comment

      Working...