---
title: "XML Schema-problem"
type: "forum-thread"
url: "https://www.webforum.nu/amne/xml/49620-xml-schema-problem"
topic: "XML"
topic_url: "https://www.webforum.nu/amne/xml"
author: "toha"
published: "2002-08-06T07:56:32.000Z"
updated: "2002-08-06T07:56:32.000Z"
replies: 0
views: 398
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/xml/49620-xml-schema-problem"
---

# XML Schema-problem

## #1 — toha, 2002-08-06T07:56Z

Har problem med att validera ett xml-dokument mot ett xml-schema:

**xml schemat: doc.xsd**

```
<?xml version="1.0"?>
<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://xsdtesting"
    elementFormDefault = "qualified">

	<xs:element name="doc">
		<xs:complexType>
			<xs:element name="notDeclared" />
		</xs:complexType>
	</xs:element>

</xs:schema>
```

**xml-dokumentet: doc.xml** 

```
<?xml version="1.0"?>
<x:doc
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    xmlns:x='http://xsdtesting'
    xsi:schemaLocation='http://xsdtesting doc.xsd'>
   <x:notDeclared/>
</x:doc>
```

 
Och validerar det genom JScriptet:

```
var x = new ActiveXObject("MSXML2.DOMDocument.4.0");
x.async = false;
x.validateOnParse = true;
x.load("doc.xml");
if (x.parseError.errorCode != 0) 
   {
     WScript.Echo("errorReason=" + x.parseError.reason); 
   }
else 
     WScript.Echo("===NO PARSE ERROR===\n" + x.xml);
```

 
Något fel ska ju inte uppstå, dock får jag felmeddelandet:

> the element 'x:doc' is used but not declared in the DTD/Schema

Det verkar som jag inte kan göra ett element till complexType eller sätta minOccurs- eller maxOccurs-attribut.

Tacksam för hjälp!

Permalänk: https://www.webforum.nu/p/49620

---

Tråden på webben: https://www.webforum.nu/amne/xml/49620-xml-schema-problem
