Avoid declaring namespaces for all top level elements

Hello all,

I apologize for my tone, I am extremely frustrated; I have wrested with this issue for many hours now.

Here’s my situation.

I have two schemas. Schema B imports schema A. After hours of frustration, and contrary to Tamino’s documentation! I have discovered that one simply cannot make schema A have a target namespace WITHOUT a prefix. Doing so let’s you define both schemas to the DB, however when you try to insert doc instances, you get the INOXDE7824 error.

Alright, so I define the target namespace prefix. Now my doctype has a prefix (very annoying). I tried therefore to give my complex top level element to which my doctype is linked also the prefix. No go, since it isn’t complient to NCName. Okay, so I leave it out. However, now I have to, for every document instance, use the prefix, and not only that, I have to declare the namespace with the prefix for each top level element (and attribute) as well. This is really really inconvenient.

Isn’t there a way aroudn this? Heck I thought (and seen a lot of examples on this NS) that in schema A, you simply declare target namespace without a prefix. In schema B, you declare the same namespace WITH a prefix, and the schemas will get linked. You can then use ref elements and attributes from the referenced schema (when you load the external schema) and the referenced items will have the prefix automatically. Once again, this all works when defining schemas, but you cannot put any doc instances into the DB (INOXDE7824).

So, what is one to do? I am very angry for the Tamino docs being wrong, for reading posts on this NS that are 2 years old (presumably from a member of the dev team) and hearing that in the next version of Tamino this (omiting target namespaces will be fixed) and we’re 2 years later and nothing has been fixed. Tech support of course doesn’t help you, they just forward the q to the dev team anyways.

(here’s that post: target namespace prefixes cannot be omitted

Any solution would be immensely appreciated, since I have scourged all the newsgroups and read all the docs, but I cannot find a good resolve to this problem.

Thank you.

Hi,

I am afraid that I do not understand your issue. Here is a schema without namespace:
<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema xmlns:tsd = “http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition” xmlns:xs = “http://www.w3.org/2001/XMLSchema”>
xs:annotation
xs:appinfo
<tsd:schemaInfo name = “A”>
<tsd:collection name = “test1”></tsd:collection>
<tsd:doctype name = “A”>
tsd:logical
tsd:contentclosed</tsd:content>
</tsd:logical>
</tsd:doctype>
</tsd:schemaInfo>
</xs:appinfo>
</xs:annotation>
<xs:import namespace = “myNS” schemaLocation = “B”></xs:import>
<xs:element name = “A” type = “xs:string”></xs:element>
</xs:schema>

which imports another schema (named B), given here for completeness:

<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema targetNamespace = “myNS” xmlns:X = “myNS” xmlns:tsd = “http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition” xmlns:xs = “http://www.w3.org/2001/XMLSchema”>
xs:annotation
xs:appinfo
<tsd:schemaInfo name = “B”>
<tsd:collection name = “test1”></tsd:collection>
<tsd:doctype name = “X:B”>
tsd:logical
tsd:contentclosed</tsd:content>
</tsd:logical>
</tsd:doctype>
tsd:adminInfo
tsd:server4.1.4.1</tsd:server>
tsd:modified2004-05-04T12:22:41.062+01:00</tsd:modified>
tsd:created2004-05-04T12:22:41.062+01:00</tsd:created>
tsd:versionTSD4</tsd:version>
</tsd:adminInfo>
</tsd:schemaInfo>
</xs:appinfo>
</xs:annotation>
<xs:element name = “B” type = “xs:string”></xs:element>
</xs:schema>

I define schema B, then schema A, then I can insert the following XML document:
<X:B xmlns:X=“myNS”/>

Tested with Tamino 4.1.4

How does your case differ from what I have done here. Obviously, I got your description wrong

Regards

Harald

Hi Hogo
(sorry - is that your real name - where are you from?)

- there are indeed some problems in Tamino when using the default namespace in a schema with a targetNamespace in conjunction with X-Query (_xql, _delete) not with XQuery
- since Tamino 4.1 the usage of a prefix in the schema is dependent of usage of prefixes in XML documents to be validated against that schema
- if a prefix is used for the targetNamespace of a schema document, the doctype may use that, but global elements are qualified implicitly (compare to description of “form” attribute in Tamino / XML Schema docu). This may look as follows:

<xs:schema xmlns:p=“URI” targetNamespace=“URI”>

<tsd:doctype name=“p:root”/>


<xs:element name=“root”>
</xs:schema>

This schema will accept either and <q:root xmlns:q=“URI”/>.

Hope this helps to clarify the issue. If not: pls provide
- the Tamino version being used
- the schema and sample document your dealing with

Best regards
Uli

Hello,

Using your example schema and instance to load (included below),
modify the ‘title’ element so that Logical Property Form is set to “qualified”.

Next, add the namespace to the instance to be loaded. i.e., <ino:request xmlns:ino=“http://namespaces.softwareag.com/tamino/response2
xmlns=“http://www.hahaha.com/main/programming-types”>

The instance will no load and no namespace prefix is used.

Is this the result you are looking for?

I made this change because the elementFormDefault / attributeFormDefault do not apply to global element or attribute definitions. “Global” means that they are immediate children of the xs:schema root node.
Global elements or attributes are ALWAYS QUALIFIED.

You can also refer to http://www.w3.org/TR/xmlschema-1/#declare-element
Read carefully through the description of the “Element Declaration Schema Component”, especially the value of the ?targetnamespace? property depending on whether the has as its parent or not.


Schema:
<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema targetNamespace = “http://www.hahaha.com/main/programming-types” id = “programming-types” xmlns = “http://www.hahaha.com/main/programming-types” xmlns:tsd = “http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition” xmlns:xs = “http://www.w3.org/2001/XMLSchema”>
xs:annotation
xs:appinfo
<tsd:schemaInfo name = “programming-types”>
<tsd:collection name = “main”></tsd:collection>
<tsd:doctype name = “identity”>
tsd:logical
tsd:contentclosed</tsd:content>
</tsd:logical>
</tsd:doctype>
</tsd:schemaInfo>
</xs:appinfo>
</xs:annotation>
<xs:element name = “identity”>
xs:complexType
xs:sequence
<xs:element name = “title” type = “xs:string”></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Instance to load
<?xml version="1.0" encoding="UTF-8"?>
<ino:request xmlns:ino=“http://namespaces.softwareag.com/tamino/response2”>
ino:object

Tex

</ino:object>
</ino:request>


Thank you,
Rob

Hello guys,

first off, I apologize for my tone in my original posting, I was very frustrated.

Ulrich, my real name is Peter, Hogo Fogo is just a nick. I’m originally from Czech rep, with german heritage, currently living in Canada.

After spending much time on the issue and trying bazillion different scenarios, and some guidance from the tech support, I have come to these conclusions:

You can, in fact define a prefix-less target namespace. However, when you import such a schema into another one, you have no choice but to declare the same namespace (as the target namespace in the 1st schema) WITH a prefix. The prefix then HAS to be used for all TOP LEVEL elements (and attributes) [in the 1st schema] that you may reference.

On top of that, you then HAVE to declare this prefix and namespace for each doc instance and then use the prefix on all the elements that were referenced in the second schema.

I guess that’s just the way things work in the XML world. I was kind of hoping to acomplish something that you can do in OOP. In OOP you can have multiple files, and if you use the same namespace in all those files, the namespace is seen as one. You have to just gurantee that in all the files where you use the same namespace, you don’t have the same class name twice. Things have to be unique. This method of using namespaces makes far more sense to me then the XML way when importing schemas. But I guess I am not seeing something or that I am being too demanding.

Thanks for your input guys!

Peter

Hi,

note that there is a distinction between import (schema with different namespace) and include (schema with same namespace)

Regards

Harald

Hi Peter

things are not that different in XML Schema when compared to OO:
all the uniqueness constraints do apply as well if you compose multiple schemas
with the same targetNamespace - but: this can only be done using xs:include
which is not yet supported by Tamino 4.1 (but will be in 4.2).
xs:import can only be used to compose schema documents with different
targetNamespaces.

Cheers
Uli

Ulrich,

that explains everything! I know that I wanted to use include before, but I know Tamino didn’t support it yet, so I stopped using it. I forgot that that’s what include was ment for (composing multiple schemas with the same target namespace).

Tamino ver 4.2 can’t be here soon enough!

Also I am curious to see if ver 4.2 will finally support some means of deriving types! This would save me a heck of a lot of problems, create schemas which are easier to maintain (less duplicate schema code).

I am sure there must be speed penalties for using derived types, but if the speed is reasonable, and the usage of derived types is reasonable as well, it could help a lot.

One can always dream!

Thank you for the clarification. Include was what I was looking for all this time then.

Peter Endisch

---------------------------------------
I’m a Zen Garden Maintenance Engineer
---------------------------------------