-1

I get this error whan trying to validate xml against xsd. Cannot find the declaration of element Transactions.knowing that the element Transactions is exists the XSD. You find below XML and XSD. ---------------XML--------------------------------

<Transactions>
    <User>userId</User>
    <RequestDate>2018-04-04T11:05:16+01:00</RequestDate>
    <Language>en_US</Language>
</Transactions>

---------------XSD-------------------------------- NB:My file contains many xsd like below.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <xs:schema version="1.0" targetNamespace="..." xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns2="imported xsd1" xmlns:ns1="imported xsd1">
      <xs:import namespace="..." schemaLocation="schema5.xsd"/>
      <xs:import namespace="..." schemaLocation="schema4.xsd"/>
      <xs:complexType name="Transactions">
        <xs:complexContent>
          <xs:extension base="ns2:...">
            <xs:sequence>
              <xs:element name="User" type="ns1:User" minOccurs="0"/>
              <xs:element name="RequestDate" type="xs:string" minOccurs="0"/>
              <xs:element name="Language" type="xs:string" minOccurs="0"/>
            </xs:sequence>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
<xs:complexType name="Other Element">
    <xs:complexContent>
      <xs:extension base="ns2:...">
        <xs:sequence>
          <xs:element name="..." type="ns1:..." minOccurs="0"/>
          <xs:element name="..." type="xs:string" minOccurs="0"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
     </xs:schema>

Any help is appreciate,please.

rbaha
  • 140
  • 1
  • 11
  • 1
    Nobody can help you without more detail than you've provided. Please [edit] your question and provide a [mcve], including the smallest XML and XSD that illustrate the problem. – kjhughes Sep 07 '18 at 16:34
  • Here is a model to follow for asking this type of question: https://stackoverflow.com/q/39738095/290085 – kjhughes Sep 07 '18 at 16:41
  • That's a lot better, but ideal would be an XSD complete enough to actually validate and reproduce your issue. From what you've shown, [we can guess...](https://stackoverflow.com/a/52228021/290085) – kjhughes Sep 07 '18 at 18:39

1 Answers1

0

Your shown XSD has a type declaration but is lacking an element declaration such as:

<xs:element name="Transactions" type="Transactions"/>

You may also have to prepend a namespace prefix ahead of Transactions in type="Transactions" if within an XSD with a target namespace.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • Thank you for your response,i have edited my question to be clair.thanks for your help. – rbaha Sep 09 '18 at 11:02
  • Your XSD *still* has no `Transactions` ***element*** declaration at the top level. – kjhughes Sep 09 '18 at 13:05
  • And your question *still* lacks a [mcve]. Re-read my [**first comment to your question**](https://stackoverflow.com/questions/52226486/cannot-find-the-declaration-of-element-xml-against-xsd/52228021?noredirect=1#comment91402453_52226486) and the model I provided you as well. In that model, the XML and XSD could be validated together by readers. You've not provided such a MCVE. – kjhughes Sep 09 '18 at 13:07