0

I have an XML string that validators are saying is invalid. The error occurs on line 2 character 1. The string is all at the same tier. It is about a hundred occurences of <map> and map has various attributes.

<map attribute_1="thomas"></map>
<map attribute_1="thomas again"></map>

That's the entire string. But I'm being told that

Line 1: Can not find declaration of element 'map'.
Line 2: The markup in the document following the root element must be well-formed.

Based on what I read in this answer, I thought that perhaps <map> needs a parent element which shares a name attribute with a child. I copy pasted the structure so I ended up with something like

<element name="details">
    <complexType>
        <sequence>
            <map name="details">
            </map>
        </sequence>
    </complexType>
</element>

It was just a shot in the dark, as my experience with XML is nil. In any case, it didn't work. What's wrong with my markup?

Community
  • 1
  • 1
1252748
  • 14,597
  • 32
  • 109
  • 229
  • 1
    That looks like a validation error not a well-formed-ness error. By which I mean that you don't have a schema documenting your xml document format so whatever tool generated those errors couldn't validate that the xml document followed the specification. That being said you should also have a single root element in a document and not multiple ones. So `......` for example. – Etan Reisner Nov 01 '13 at 15:39
  • @EtanReisner wrapping the entire document with `...` now gives me the error `Can not find declaration of element 'root'.` Re: schema, how can I add this? Thank you. – 1252748 Nov 01 '13 at 15:42
  • 1
    You either write an xml schema document (xsd) for your document or you tell your tool to stop trying to validate the document against a schema. – Etan Reisner Nov 01 '13 at 15:46

2 Answers2

1

Your XML should be like

<?xml version="1.0" encoding="UTF-8"?>
<maps>
<map attribute_1="thomas"></map>
<map attribute_1="thomas again"></map>
</maps>

try this

Sid M
  • 4,354
  • 4
  • 30
  • 50
0

It's not clear how you are processing the document at the point you get the error, but you need to make a choice:

(a) if you want to validate the document against a schema, you need to supply a schema.

(b) if you don't want to validate the document against a schema, you need to change the way you are processing it so validation isn't attempted.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164