473,654 Members | 2,990 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[XML Schema] Error "content model is not determinist"

Hello,

I'd like to write a single XML Schema for both these documents :

<Items>
<Item xml:id="id1">
<Name>ABC</Name>
...
</Item>
<Item xml:id="id2">
<Name>DEF</Name>
...
</Item>
...
</Items>

and

<Items>
<Item ref="id1"/>
<Item ref="id2"/>
...
</Items>

That looks "easy", but I've been googling for hours and tried so many
differents combinations of <choiceand <sequence>'s. .. and yet it
doesn't work :/
All I got at best were errors saying "local complex type: The content
model is not determinist" -- because the element name "Item" is used in
both "types" of elements IIUC.

Maybe using more complex OO features of XML Schema would somehow help me
out?

Cheers,

--
Damiano ALBANI
Aug 21 '06 #1
5 7157
Damiano ALBANI wrote:
Hello,

I'd like to write a single XML Schema for both these documents :
....

How about a schema that declares:
- Items elements to contain any number of Item elements (maybe any
number 0, up to you)
- Item elements to have an optional id attribute, an optional ref
attribute and a sequence of Name sub-elements of length 0 or 1
That looks "easy", but I've been googling for hours and tried so many
differents combinations of <choiceand <sequence>'s. .. and yet it
doesn't work :/
You will have to tell us about what it must be able to do, what you
tried, what you expected and what you got....

One solution is to approximate Items to contain anything at all. That
will work -- but is that good enough for your requirements?
All I got at best were errors saying "local complex type: The content
model is not determinist" -- because the element name "Item" is used in
both "types" of elements IIUC.

Maybe using more complex OO features of XML Schema would somehow help me
out?
NO. They will only make it worse ;)

An XML Schema must be written in such a way that it can be <<determined
immediately when parsing what branch of a content model to use>(my
formulation; The XML Schema spec has some formally correct but so
complicated that you can't read it ways to say that).

Example

<element name="goat">
<complexType>
<choice>
<sequence>
<element name="foo"/>
<element name="bar"/>
</sequence>
<sequence>
<element name="foo"/>
<element name="baz"/>
</sequence>
</choice>
</complexType>
</element>

--- when validating:
<goat>
<foo/>
<baz/>
</goat>

(which is valid), the schema must be constructed that the validator,
when it sees the <foo/element, does not have to _guess_ whether to
continue validating as
<sequence>
<element name="foo"/>
<element name="bar"/>
</sequence>

or

<sequence>
<element name="foo"/>
<element name="baz"/>
</sequence>

You have probably made that mistake ;)

A possible fix is:

<element name="goat">
<complexType>
<sequence>
<element name="foo"/>
<choice>
<element name="bar"/>
<element name="baz"/>
</choice>
</sequence>
</complexType>
</element>
Hope that helped.

Søren
Aug 21 '06 #2
Thanks for the tips Soren !

Here's what I wrote, which works quite well -- not perfectly, but the
best I could thought of :

<xsd:group name="Item_Cont ent">
<xsd:sequence >
<xsd:element name="Name"
type="xsd:strin g"/>
<xsd:element name="Type"
type="xsd:strin g"/>
...
</xsd:sequence>
</xsd:group>
<xsd:complexTyp e name="Item_Type ">
<xsd:group ref="Item_Conte nt"
minOccurs="0"
maxOccurs="1"/>
<xsd:attribut e name="id"
type="xsd:ID"/>
<xsd:attribut e name="ref"
type="xsd:IDREF "/>
</xsd:complexType >

So, the only problem is that an Item element with both (content + @id)
_and_ @ref attribute is considered valid.

In my real-world application, I don't manipulate simply Item elements
but there's several complex element types. So that means I need to write
many "dual" element definitions (content through <xsd:group+ actual
type referring to that group). As I'm no expert in XML Schema, would
there be a way to avoid this redundancy ?

Cheers,

--
Damiano ALBANI
Aug 22 '06 #3
Damiano ALBANI wrote:
Thanks for the tips Soren !
Happy to be of help
So, the only problem is that an Item element with both (content + @id)
_and_ @ref attribute is considered valid.
Can't do anything about that. Attribute inter-dependencies are not
supported in XSD.
In my real-world application, I don't manipulate simply Item elements
but there's several complex element types. So that means I need to write
many "dual" element definitions (content through <xsd:group+ actual
type referring to that group). As I'm no expert in XML Schema, would
there be a way to avoid this redundancy ?
Sorry, don't understand that. Could you post an example?

Søren
Aug 23 '06 #4
Soren Kuula wrote:
>So, the only problem is that an Item element with both (content + @id)
_and_ @ref attribute is considered valid.

Can't do anything about that. Attribute inter-dependencies are not
supported in XSD.
Okay.
>In my real-world application, I don't manipulate simply Item elements
but there's several complex element types. So that means I need to
write many "dual" element definitions (content through <xsd:group+
actual type referring to that group). As I'm no expert in XML Schema,
would there be a way to avoid this redundancy ?

Sorry, don't understand that. Could you post an example?
I was referring to the example in my post. For each element type, I need
to define :

* a <xsd:group>
* a <xsd:complexTyp e>, using the previous <xsd:group>

So I was thinking of an XML Schema construct to avoid "leaking"
<xsd:groupdefin itions outside <xsd:complexTyp ewhere they are used.
No big deal, but that would make the final schema a bit "cleaner".

Cheers,

--
Damiano ALBANI
Aug 25 '06 #5
Damiano ALBANI wrote:
Soren Kuula wrote:
>>So, the only problem is that an Item element with both (content +
@id) _and_ @ref attribute is considered valid.


Can't do anything about that. Attribute inter-dependencies are not
supported in XSD.


Okay.
>>In my real-world application, I don't manipulate simply Item elements
but there's several complex element types. So that means I need to
write many "dual" element definitions (content through <xsd:group+
actual type referring to that group). As I'm no expert in XML Schema,
would there be a way to avoid this redundancy ?


Sorry, don't understand that. Could you post an example?


I was referring to the example in my post. For each element type, I need
to define :

* a <xsd:group>
* a <xsd:complexTyp e>, using the previous <xsd:group>

So I was thinking of an XML Schema construct to avoid "leaking"
<xsd:groupdefin itions outside <xsd:complexTyp ewhere they are used.
No big deal, but that would make the final schema a bit "cleaner".
Well you don't *have* to use a group when making a complex type. I think
you can always replace a group reference by the content of the referred
group. It's just a sort of macro mechanism.

Søren
Aug 27 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
7149
by: Michael Strorm | last post by:
Hi! I've been having problems with a DTD. Having had the Sun XML validator reject a document, I put it through 'xmllint' for more information. 'Xmllint' noted a problem with the DTD itself; "validity error : Content model of section is not determinist: (text , (list , text)* , list?)" Here's a very simplified version of the DTD demonstrating the problem:-
12
2867
by: Jean-Marc Blaise | last post by:
Hi Folks, I'm getting this message with the XML tutorial: getstart_exportXML.cmd file: SQL0444N Routine "DB2XML.CONTENT" (specific name "DB2XMLCONTENTVF") is implemented with code in library or path "\db2xmlfn", function "dxxContent_varchar2file" which cannot be accessed. Reason code: "4". SQLSTATE=42724 DB20000I The TERMINATE command completed successfully.
0
5386
by: Brett | last post by:
I have an XML file that is the documentation for an application. Text log files are in a different location than the XML file. For example: c:\adir\errorlog.txt c:\bdir\doc.xml The VB.NET project is located in c:\bdir The XML file is part of the project but I actually need it to be in the same directory as the text log files. I moved the XML to c:\adir. I'd like to
0
1629
by: J.Edwards | last post by:
I'm getting this error when trying to use a control built in VS 2003 (1.1) in a new asp project in VS 2005. "Content controls can only be used in a content page" The control has always worked ok in 2003, and I've not seen this error before so does anyone know what it could be? Can't find anything on the web about it.
0
1893
by: Phil | last post by:
I am writing an application (using Visual Studio 2003) that consumes a third party Web Service, but I receive the following error : Client found response content type of 'application/xml; charset=utf-8', but expected 'text/xml'. I can see the XML Document and it is properly structured. Is there any way to overide this and get .NET to process the response XML regardless of the Content Type Setting in the HTTP Response ?
6
1672
by: Lord0 | last post by:
Hi there, How do I define in a schema that an element (<element>) may have any content i.e. text, other elements, partial elements, angle brackets etc? So all of the following would be valid: <element> aaaaaaa<foo/>bbbbbb<bar/>cccccc
1
2272
by: dave8421 | last post by:
Hi, I'm trying to make sense of the definition for "Rendered Content" in current CR for CSS 2.1 Is rendered content what is displayed on the particular media or device? from the definitions, I got the impression that the rendered content is referring to the source document and not the particular
4
8778
by: dmvsatyakumar | last post by:
Hi Alll, When i try to parse the string.xml which is in UTF-16LE, its working fine with JDK 1.4 but gives the following error in JDK 1.5. Error : "Content is not allowed in prolog". Can any one of you suggest me a solution for this. Its very urgent.
3
7046
by: Alexander Smirnov | last post by:
I'm developing asp.net 2 web application and need to make a custom http handler which sometime must send response with "204 No Content" code. I set HttpResponse.Status="204 No Content"; But asp automatically adds headers such as "Content-Length: 0". This causes an error on the client. HttpResponse.ClearHeaders() doesn't help. How to make asp not to add headers (especially Content- Length)? Thanks in advance.
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.