What's wrong with your XML is that it is not well-formed.
That is, it does not meet the basic requirements for being XML. Then, per your comment about an error indicating that collection-list
cannot be found, your XML is also not valid. That is, it does not meet the additional requirements specified by a schema. You might want to read more about Well-formed vs Valid XML in general.
Below, I will help you with each category of problems in your particular case. I will use Xerces-J error message to be concrete, but similar errors will be issued by any conformant XML parser.
Well-Formed
[Fatal Error] try.xml:9:31: Element type "member" must be followed by either attribute specifications, ">" or "/>".
- Explanation: Parser cannot complete processing of
member
, indicating a problem while parsing the attributes (before getting to
the end of the opening tag as marked by >
or />
.
- Resolution: Add whitespace before the
default-view="tableview"
attribute.
[Fatal Error] try.xml:12:5: The element type "xs:collection" must be terminated by the matching end-tag "</xs:collection>"
.
- Explanation: Parser sees no closing
</xs:collection>
because the namespace prefix is missing on </collection>
.
- Resolution: Add the namespace prefix to the closing
collection
tag.
Repeat for collection-list
.
Other notes:
- I would reserve the
xs
namespace prefix for XML Schema
elements (although this isn't strictly necessary).
- I would remove the
elementFormDefault
attribute from hp:collection-list
as it looks like it mistakenly has been copied over from an XSD.
- I'll assume that the
member
element is also intended to be in the http://www.hp.com/hpsim7.5.0.0
namespace to simplify demonstrating an XSD for your XML in the next section.
Altogether, then, here is your text turned into well-formed XML:
<?xml version="1.0" encoding="UTF-8" ?>
<hp:collection-list xmlns:hp="http://www.hp.com/hpsim7.5.0.0">
<hp:collection name="abc"
type="system"
parent="Systems by Type">
<hp:member name="All Servers"
type="query"
display-status="0"
default-view="tableview"
hidden="false"/>
</hp:collection>
</hp:collection-list>
Valid
Now that you have well-formed XML, you can proceed to attempt to validate it, but when you do, you'll encounter another error:
[Error] try.xml:3:52: cvc-elt.1.a: Cannot find the declaration of
element 'hp:collection-list'.
- Explanation: Parser cannot find an XSD for the elements in this file, starting with the root element,
hp:collection-list
.
- Resolution: Hint to the parser where to look for the XSD using
xsi:schemaLocation
, whose value consists of namespace-location pairs, separated by spaces.
Here is your XML with xsi:schemaLocation
hinting the XSD location:
<?xml version="1.0" encoding="UTF-8" ?>
<hp:collection-list xmlns:hp="http://www.hp.com/hpsim7.5.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hp.com/hpsim7.5.0.0 try.xsd">
<hp:collection name="abc"
type="system"
parent="Systems by Type">
<hp:member name="All Servers"
type="query"
display-status="0"
default-view="tableview"
hidden="false" />
</hp:collection>
</hp:collection-list>
And here is an XSD that validates the above XML:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.hp.com/hpsim7.5.0.0">
<xs:element name="collection-list">
<xs:complexType>
<xs:sequence>
<xs:element name="collection" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="member">
<xs:complexType>
<xs:sequence/>
<xs:attribute name="name"/>
<xs:attribute name="type"/>
<xs:attribute name="display-status" type="xs:integer"/>
<xs:attribute name="default-view"/>
<xs:attribute name="hidden" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name"/>
<xs:attribute name="type"/>
<xs:attribute name="parent"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>