Jump to content

XML document must have a top level element


CMCollins

Recommended Posts

I've been staring at this for hours and searching forums for an answer. I have also gotten this message from another validator: "Character 'P' following the text '<' does not fulfill production 'Misc', which highlights the first start tag of <Product>. Could anyone recommend a solution? As far as I can tell I only have one root element, but maybe I'm missing something.
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:include schemaLocation="amzn-base.xsd"/>
<xsd:element name="product">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="asin" type="xsd:string"/>
<xsd:element name="brand" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="category" type="xsd:string"/>
<xsd:element name="description" type="xsd:string"/>
<xsd:element name="wordcount" type="xsd:string"/>
<xsd:element name="rating" type="xsd:string"/>
<xsd:element name="review" type="xsd:string"/>
<xsd:element name="listprice" type="xsd:string"/>
<xsd:element name="price" type="xsd:string"/>
<xsd:element name="discount" type="xsd:string"/>
<xsd:element name="shipping" type="xsd:string"/>
<xsd:element name="totalprice" type="xsd:string"/>
<xsd:element name="parentasin" type="xsd:string"/>
<xsd:element name="available" type="xsd:string"/>
<xsd:element name="fulfilled" type="xsd:string"/>
<xsd:element name="thumbnail" type="xsd:string"/>
<xsd:element name="url" type="xsd:string"/>
<xsd:element name="imageurl" type="xsd:string"/>
<xsd:element name="salesrank" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<Product>
<ASIN>B003Y3E55G</ASIN>
<Brand>Hydrofarm</Brand>
<Title>Hydrofarm CK64081 7-Inch Vented Dome</Title>
<Category>Patio, Lawn & Garden</Category>
<Description>Hydrofarm ck64081 7-inch vented humidity dome</Description>
<WordCount>6</WordCount>
<Rating>3.7</Rating>
<Review>87</Review>
<ListPrice>0</ListPrice>
<Price>12.88</Price>
<Discount>0%</Discount>
<Shipping>0</Shipping>
<TotalPrice>0</TotalPrice>
<ParentASIN>B003Y3E55G</ParentASIN>
<Available>True</Available>
<Fulfilled>False</Fulfilled>
<Description>Vented humidity dome * Easy dial vents for precise control of temperature and humidity * Durable, high-grade flexible plastic resists cracking * Designed to last longer * Great for taller cuttings * 7-inch dome gives extra height for your taller cuttings * Adjustable vents allow for perfect humidity and temperature control</Description>
<SalesRank>2917</SalesRank>
</Product>
Link to comment
Share on other sites

It's okay, that it apart of programming in my book; To look at a screen for hours and then seeing the problem was as simple as a typo.In your schema product is spell "product". In your XML, you have product as "Product".In XML's world; Product, and product are two different element.All XML element must match exactly with the schema defined element name.When an XML parser in counter an error, it stop parsing and report the error. Looking at your XML... It seem all element does not match up with the schema. If must match exactly with the schema, Capital and all.If this help you, please consider giving me a like in the upper right corner.

Edited by L8V2L
Link to comment
Share on other sites

That doesn't seem to help. I've tried using Find/Replace to make them all upper case and all lower case, and no luck yet. I appreciate your efforts tho.

What's does the error message say after you correctly match the element to the corresponding schema's elements.
Link to comment
Share on other sites

When I try to open it in excel I getXML document must have a top level element XMLSpy saysCharacter 'P' following the text '<' does not fulfill production 'Misc'. http://www.xmlvalidation.com/ says31: 2 The markup in the document following the root element must be well-formed.

Take the schema link out. And then see what it say.
Link to comment
Share on other sites

I took out these two lines:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:include schemaLocation="amzn-base.xsd"/>
and
</xsd:schema>
Now

 

XMLValidation.com says:

The prefix "xsd" for element "xsd:element" is not bound.

 

XMLSpy still says:

Character 'P' following the text '<' does not fulfill production 'Misc'.

 

And when I try to open it in Excel I get:

Strict Parse Error

Link to comment
Share on other sites

I took out these two lines:<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><xsd:include schemaLocation="amzn-base.xsd"/>and</xsd:schema> Now XMLValidation.com says:The prefix "xsd" for element "xsd:element" is not bound. XMLSpy still says:Character 'P' following the text '<' does not fulfill production 'Misc'. And when I try to open it in Excel I get:Strict Parse Error

Do me a favor. Change all capitals letters to lower case, and re-paste both of them files here.Cause it tell you that you have a capital P, which doesn't match up to the schema rule or you have a mismatch tag. So I would like to see the correction you made.Like I said, these things can be as simple as a typo. That's the world of programming.
Link to comment
Share on other sites

You do realise you have two descriptions elements, and the last one throws it out of sequence to read salesrank

<?xml version="1.0"?><product>    <asin>B003Y3E55G</asin>    <brand>Hydrofarm</brand>    <title>Hydrofarm CK64081 7-Inch Vented Dome</title>    <category>Patio, Lawn &amp; Garden</category><description>Hydrofarm ck64081 7-inch vented humidity dome</description>   <wordcount>6</wordcount>    <rating>3.7</rating>    <review>87</review>    <listprice>0</listprice>    <price>12.88</price>    <discount>0%</discount>    <shipping>0</shipping>    <totalprice>0</totalprice>    <parentasin>B003Y3E55G</parentasin>    <available>True</available>    <fulfilled>False</fulfilled>    <thumbnail>http://ecx.images-am...VIL._AA160_.jpg</thumbnail>    <url>http://www.amazon.co...#38;amp;sr=1-24</url>    <imageurl>http://ecx.images-am...VIL._SS500_.jpg</imageurl><salesrank>2917</salesrank>   </product>

and this

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">    <xsd:include schemaLocation="amzn-base.xsd"/>    <xsd:element name="product">        <xsd:complexType>            <xsd:sequence>                <xsd:element name="asin" type="xsd:string"/>                <xsd:element name="brand" type="xsd:string"/>                <xsd:element name="title" type="xsd:string"/>                <xsd:element name="category" type="xsd:string"/><xsd:element name="description" type="xsd:string"/>                <xsd:element name="wordcount" type="xsd:string"/>                <xsd:element name="rating" type="xsd:string"/>                <xsd:element name="review" type="xsd:string"/>                <xsd:element name="listprice" type="xsd:string"/>                <xsd:element name="price" type="xsd:string"/>                <xsd:element name="discount" type="xsd:string"/>                <xsd:element name="shipping" type="xsd:string"/>                <xsd:element name="totalprice" type="xsd:string"/>                <xsd:element name="parentasin" type="xsd:string"/>                <xsd:element name="available" type="xsd:string"/>                <xsd:element name="fulfilled" type="xsd:string"/>                <xsd:element name="thumbnail" type="xsd:string"/>                <xsd:element name="url" type="xsd:string"/>                <xsd:element name="imageurl" type="xsd:string"/><xsd:element name="salesrank" type="xsd:string"/>                </xsd:sequence>        </xsd:complexType>    </xsd:element></xsd:schema>

validates at http://www.freeformatter.com/xml-validator-xsd.html , change description to correct one.

Edited by dsonesuk
Link to comment
Share on other sites

You do realise you have two descriptions elements, and the last one throws it out of sequence to read salesrank

<?xml version="1.0"?><product>    <asin>B003Y3E55G</asin>    <brand>Hydrofarm</brand>    <title>Hydrofarm CK64081 7-Inch Vented Dome</title>    <category>Patio, Lawn &amp; Garden</category><description>Hydrofarm ck64081 7-inch vented humidity dome</description>   <wordcount>6</wordcount>    <rating>3.7</rating>    <review>87</review>    <listprice>0</listprice>    <price>12.88</price>    <discount>0%</discount>    <shipping>0</shipping>    <totalprice>0</totalprice>    <parentasin>B003Y3E55G</parentasin>    <available>True</available>    <fulfilled>False</fulfilled>    <thumbnail>http://ecx.images-am...VIL._AA160_.jpg</thumbnail>    <url>http://www.amazon.co...#38;amp;sr=1-24</url>    <imageurl>http://ecx.images-am...VIL._SS500_.jpg</imageurl>
and this
<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
validates at http://www.freeformatter.com/xml-validator-xsd.html , change description to correct one.
AWWWW!!!! You're taking my likes!!!!
Link to comment
Share on other sites

I have changed all the tags I created to lower case and I took out the 2nd Description tag.  I'm still getting these error messages:

 

XMLspy:

Character 'p' following the text '<' does not fulfill production 'Misc'.

 

Excel:

Only one top level element is allowed in an xml document

 

XMLValidation

The markup in the document following the root element must be well-formed.

 

http://www.freeformatter.com/xml-validator-xsd.html

The Markup In The Document Following The Root Element Must Be Well-formed.

 

The latest version is below:

 

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><xsd:include schemaLocation="amzn-base.xsd"/><xsd:element name="product"><xsd:complexType><xsd:sequence>  <xsd:element name="asin" type="xsd:string"/>    <xsd:element name="brand" type="xsd:string"/>    <xsd:element name="title" type="xsd:string"/>    <xsd:element name="category" type="xsd:string"/>  <xsd:element name="description" type="xsd:string"/>  <xsd:element name="wordcount" type="xsd:string"/>  <xsd:element name="rating" type="xsd:string"/>  <xsd:element name="review" type="xsd:string"/>  <xsd:element name="listprice" type="xsd:string"/>  <xsd:element name="price" type="xsd:string"/>  <xsd:element name="discount" type="xsd:string"/>  <xsd:element name="shipping" type="xsd:string"/>  <xsd:element name="totalprice" type="xsd:string"/>  <xsd:element name="parentasin" type="xsd:string"/>  <xsd:element name="available" type="xsd:string"/>  <xsd:element name="fulfilled" type="xsd:string"/>  <xsd:element name="thumbnail" type="xsd:string"/>  <xsd:element name="url" type="xsd:string"/>  <xsd:element name="imageurl" type="xsd:string"/>  <xsd:element name="salesrank" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema><Product>  <asin>B003Y3E55G</asin>  <brand>Hydrofarm</brand>  <title>Hydrofarm CK64081 7-Inch Vented Dome</title>  <category>Patio, Lawn &amp; Garden</Category>  <description>Hydrofarm ck64081 7-inch vented humidity dome</description>  <wordcount>6</wordcount>  <rating>3.7</rating>  <review>87</review>  <listprice>0</listprice>  <price>12.88</price>  <discount>0%</discount>  <shipping>0</shipping>  <totalprice>0</totalprice>  <parentasin>B003Y3E55G</parentasin>  <available>True</available>  <fulfilled>False</fulfilled>  <thumbnail>http://ecx.images-am...VIL._AA160_.jpg</thumbnail>  <url>http://www.amazon.co...#38;amp;sr=1-24</URL>  <imageurl>http://ecx.images-am...VIL._SS500_.jpg</imageurl>  <salesrank>2917</salesrank></product> 

Link to comment
Share on other sites

I have changed all the tags I created to lower case and I took out the 2nd Description tag.  I'm still getting these error messages: XMLspy:Character 'p' following the text '<' does not fulfill production 'Misc'. Excel:Only one top level element is allowed in an xml document XMLValidationThe markup in the document following the root element must be well-formed. http://www.freeformatter.com/xml-validator-xsd.htmlThe Markup In The Document Following The Root Element Must Be Well-formed. The latest version is below: <?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><xsd:include schemaLocation="amzn-base.xsd"/><xsd:element name="product"><xsd:complexType><xsd:sequence>  <xsd:element name="asin" type="xsd:string"/>    <xsd:element name="brand" type="xsd:string"/>    <xsd:element name="title" type="xsd:string"/>    <xsd:element name="category" type="xsd:string"/>  <xsd:element name="description" type="xsd:string"/>  <xsd:element name="wordcount" type="xsd:string"/>  <xsd:element name="rating" type="xsd:string"/>  <xsd:element name="review" type="xsd:string"/>  <xsd:element name="listprice" type="xsd:string"/>  <xsd:element name="price" type="xsd:string"/>  <xsd:element name="discount" type="xsd:string"/>  <xsd:element name="shipping" type="xsd:string"/>  <xsd:element name="totalprice" type="xsd:string"/>  <xsd:element name="parentasin" type="xsd:string"/>  <xsd:element name="available" type="xsd:string"/>  <xsd:element name="fulfilled" type="xsd:string"/>  <xsd:element name="thumbnail" type="xsd:string"/>  <xsd:element name="url" type="xsd:string"/>  <xsd:element name="imageurl" type="xsd:string"/>  <xsd:element name="salesrank" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema>

You still have this p in capital. Change it.

<Product>  <asin>B003Y3E55G</asin>  <brand>Hydrofarm</brand>  <title>Hydrofarm CK64081 7-Inch Vented Dome</title>  <category>Patio, Lawn &amp; Garden</Category>  <description>Hydrofarm ck64081 7-inch vented humidity dome</description>  <wordcount>6</wordcount>  <rating>3.7</rating>  <review>87</review>  <listprice>0</listprice>  <price>12.88</price>  <discount>0%</discount>  <shipping>0</shipping>  <totalprice>0</totalprice>  <parentasin>B003Y3E55G</parentasin>  <available>True</available>  <fulfilled>False</fulfilled>  <thumbnail>http://ecx.images-am...VIL._AA160_.jpg</thumbnail>  <url>http://www.amazon.co...#38;amp;sr=1-24</URL>  <imageurl>http://ecx.images-am...VIL._SS500_.jpg</imageurl>  <salesrank>2917</salesrank></product> 

The two product root element tags does not match. Lower case. <product></product>
Link to comment
Share on other sites

The url element has a capitalized closing tag.

Exactly how are you opening these files, i say these files because there should be one .xml and one xsd both starting with <?xml version="1.0"?>, i say this because your provided code always show these as combined with only one <?xml version="1.0"?>.

 

From what i understand, you should be using the excel (2010) developer tab, XMLsource pane and XML maps button

http://msdn.microsoft.com/en-us/library/office/gg469857%28v=office.14%29.aspx wrong link

 

better link http://office.microsoft.com/en-gb/excel-help/map-and-unmap-xml-elements-HP010206397.aspx

 

look under create xml map.

 

When you use file open, you do get that error message, with combined xml and xsd files.

Edited by dsonesuk
Link to comment
Share on other sites

I found the other capitals in the tags and removed them, and get the same messages.

 

I've been trying to use an internal dtd because I haven't found any good directions for how to create and use an external one. Which lines is it supposed to contain, and where is it stored, just in the same folder as the xml? What software do you use to create one?

Link to comment
Share on other sites

The xml dtd have been replaced by xsd and must be in separate file with .xsd extension, it can be placed any where you like, you just link to it, and like xml it must have <?xml version="1.0"?> at the top. How did you create current xsd? you just do the same but save/export as separate .xsd file instead.

Link to comment
Share on other sites

linking to xsd from xml, link can be url address or link to file on computer by adding to product root element

xsd:noNamespaceSchemaLocation="file location on computer"

Note: I cant add file link example directly as example as it is removed

 

[s]where 'YourProfileName' is your specific profile name where your documents are stored[/s]

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><product xsd:noNamespaceSchemaLocation="file location on computer or url" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance">    <asin>B003Y3E55G</asin>    <brand>Hydrofarm</brand>    <title>Hydrofarm CK64081 7-Inch Vented Dome</title>    <category>Patio, Lawn &amp; Garden</category>    <description>Hydrofarm ck64081 7-inch vented humidity dome</description>    <wordcount>6</wordcount>    <rating>3.7</rating>    <review>87</review>    <listprice>0</listprice>    <price>12.88</price>    <discount>0%</discount>    <shipping>0</shipping>    <totalprice>0</totalprice>    <parentasin>B003Y3E55G</parentasin>    <available>True</available>    <fulfilled>False</fulfilled>    <thumbnail>http://ecx.images-am...VIL._AA160_.jpg</thumbnail>    <url>http://www.amazon.co...#38;amp;sr=1-24</url>    <imageurl>http://ecx.images-am...VIL._SS500_.jpg</imageurl>    <salesrank>2917</salesrank></product>

With this you just open it like any other document, and .xsd file is found instantly without the need to map to it.

 

http://www.herongyang.com/XML-Schema/XMLPad-Assign-XML-Schema-to-XML-Document.html

Edited by dsonesuk
Link to comment
Share on other sites

linking to xsd from xml, link can be url address or link to file on computer by adding to product root element

xsd:noNamespaceSchemaLocation="file location on computer"
Note: I cant add file link example directly as example as it is removed where 'YourProfileName' is your specific profile name where your documents are stored
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><product xsd:noNamespaceSchemaLocation="file location on computer or url" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance">    <asin>B003Y3E55G</asin>    <brand>Hydrofarm</brand>    <title>Hydrofarm CK64081 7-Inch Vented Dome</title>    <category>Patio, Lawn &amp; Garden</category>    <description>Hydrofarm ck64081 7-inch vented humidity dome</description>    <wordcount>6</wordcount>    <rating>3.7</rating>    <review>87</review>    <listprice>0</listprice>    <price>12.88</price>    <discount>0%</discount>    <shipping>0</shipping>    <totalprice>0</totalprice>    <parentasin>B003Y3E55G</parentasin>    <available>True</available>    <fulfilled>False</fulfilled>    <thumbnail>http://ecx.images-am...VIL._AA160_.jpg</thumbnail>    <url>http://www.amazon.co...#38;amp;sr=1-24</url>    <imageurl>http://ecx.images-am...VIL._SS500_.jpg</imageurl>
With this you just open it like any other document, and .xsd file is found instantly without the need to map to it. http://www.herongyang.com/XML-Schema/XMLPad-Assign-XML-Schema-to-XML-Document.html
You took my like!!!!
Link to comment
Share on other sites

Getting there.  Thanks dsonesuk for the two lines at the beginning of the xml.

 

This is the error I'm getting on the xml at the moment:

Element type "xsd:noNamespaceSchemaLocation" must be followed by either attribute specifications, ">" or "/>".

 

Here is the current xml, and the xsd follows:

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xsd:noNamespaceSchemaLocation="file:C:UsersCherylMy Documentsxsd_090114.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"><product>  <asin>B003Y3E55G</asin>  <brand>Hydrofarm</brand>  <title>Hydrofarm CK64081 7-Inch Vented Dome</title>  <category>Patio, Lawn &amp; Garden</category>  <description>Hydrofarm ck64081 7-inch vented humidity dome</description>  <wordcount>6</wordcount>  <rating>3.7</rating>  <review>87</review>  <listprice>0</listprice>  <price>12.88</price>  <discount>0%</discount>  <shipping>0</shipping>  <totalprice>0</totalprice>  <parentasin>B003Y3E55G</parentasin>  <available>True</available>  <fulfilled>False</fulfilled>  <thumbnail>http://ecx.images-am...VIL._AA160_.jpg</thumbnail>  <url>http://www.amazon.co...#38;amp;sr=1-24</url>  <imageurl>http://ecx.images-am...VIL._SS500_.jpg</imageurl>  <salesrank>2917</salesrank></product>

 

xsd content:

 

<?xml version="1.0"?><xsd:element name="product"><xsd:complextype><xsd:sequence>  <xsd:element name="asin" type="xsd:string"/>    <xsd:element name="brand" type="xsd:string"/>    <xsd:element name="title" type="xsd:string"/>    <xsd:element name="category" type="xsd:string"/>  <xsd:element name="description" type="xsd:string"/>  <xsd:element name="wordcount" type="xsd:string"/>  <xsd:element name="rating" type="xsd:string"/>  <xsd:element name="review" type="xsd:string"/>  <xsd:element name="listprice" type="xsd:string"/>  <xsd:element name="price" type="xsd:string"/>  <xsd:element name="discount" type="xsd:string"/>  <xsd:element name="shipping" type="xsd:string"/>  <xsd:element name="totalprice" type="xsd:string"/>  <xsd:element name="parentasin" type="xsd:string"/>  <xsd:element name="available" type="xsd:string"/>  <xsd:element name="fulfilled" type="xsd:string"/>  <xsd:element name="thumbnail" type="xsd:string"/>  <xsd:element name="url" type="xsd:string"/>  <xsd:element name="imageurl" type="xsd:string"/>  <xsd:element name="salesrank" type="xsd:string"/></xsd:sequence></xsd:complextype></xsd:element></xsd:schema>

Link to comment
Share on other sites

its difficult to show how it should look as the it will be cleared as an hack injection attempt.

 

it should be

<product xsd:noNamespaceSchemaLocation="file:C:UsersCherylMy Documentsxsd_090114.xsd" xmlns:xsd="http://www.w3.org/20...Schema-instance">

link to file should start with

 

'file:' and followed by three forward slashes '///' AS described in link in my last post


note slash direction all should match

 

go to folder where xsd folder is located, in location bar right click and select 'copy address as text' (windows7) this will give true location text as 'my documents' is alias for 'Documents', and change slashes to face opposite direction, so it may be similar to

C:/Cheryl/Documents/

Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...