473,473 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

The referenced element is undefined

Hi!

I'm new to XML schemas; can somebody explain why bar is undefined?

<xs:element name="bar">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

<xs:element name="foo">
<xs:complexType>
<xs:sequence>
<xs:element ref="bar" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
Jul 20 '05 #1
4 3266
Hi,

It's probably a namespace issue. If your schema has a target namespace,
you need to either

1. Make that namespace the default namespace, as in:

<xs:schema targetNamespace="xxx" xmlns="xxx" ....

OR

2. Give that namespace a prefix, and use the prefix in the element
reference, as in:

<xs:schema targetNamespace="xxx" xmlns:pre="xxx"
....

<xs:element ref="pre:bar" maxOccurs="unbounded"/>
Hope that helps,
Priscilla

-----------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema (Prentice Hall PTR)
-----------------------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #2
Priscilla Walmsley wrote:
It's probably a namespace issue. If your schema has a target namespace,
you need to either


So the schema (Listing 2) at
http://www-106.ibm.com/developerwork...tml?ca=dnt-520
isn't valid at all?

I actually tried it with an example schema included in the Apache JaxMe
distribution which has this definition:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="EN"
targetNamespace="http://ws.apache.org/jaxme/examples/misc/address"
elementFormDefault="qualified" attributeFormDefault="unqualified">
Jul 20 '05 #3
> So the schema (Listing 2) at
http://www-106.ibm.com/developerwork...2.html?ca=dnt-
520isn't valid at all?


No, I said "If your schema has a target namespace". That one's fine
because it doesn't have a target namespace.

The second example you gave me:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="EN"
targetNamespace="http://ws.apache.org/jaxme/examples/misc/address"
elementFormDefault="qualified" attributeFormDefault="unqualified">

Using this schema, because it DOES have a target namespace, you DO need
a namespace declaration for the target namespace BUT ONLY IF you are
planning to reference other components (e.g. element ref="xxx:bar").

If you show me your whole schema I can probably explain better...

Priscilla
-----------------------------------------------------
Priscilla Walmsley pr*******@walmsley.com
Author, Definitive XML Schema (Prentice Hall PTR)
-----------------------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4
Priscilla Walmsley wrote:
If you show me your whole schema I can probably explain better...


Got it working thanks. Watch out for another posting of mine :-)
Jul 20 '05 #5

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

Similar topics

21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
3
by: Razzbar | last post by:
What is the preferred method of removing the tagging of an element without removing the text? IOW, how do I turn this <span>I want to keep this <strong>and this, too</strong> but not...
6
by: Luke Dalessandro | last post by:
I'm not sure if this is the correct forum for platform specific (Mozilla/Firefox) javascript problems, so just shout and point me to the correct newsgroup if I'm being bad. Here's the deal... ...
1
by: jason.lucey | last post by:
Hi, I cannot get this figured out. I need to get the text out of an element node. In IE, I can do it like this: xNode(0).text but that does not work for Mozilla. And since element nodes...
1
by: Jean Stax | last post by:
Hi ! I created a sample library project. In my second project I reference this library and make the following call, which returns "undefined value": Type myType =...
2
by: Moses | last post by:
Hi All, Is is possible to catch the error of an undefined element while creating an object for it. Consider we are not having an element with id indicator but we are trying to make the object...
10
by: rush2 | last post by:
Having an odd issue that I didn't have with Opera until the most recent update to 9.22. I have a DHTML menu that I thought I was done with until yesterday. I have a root node that when a user enters...
5
by: dmorand | last post by:
I'm trying to validate whether or not an array element has been created. Here is what one of the arrays could look like: commentid = undefined commentid = undefined commentid = 1 commentid =...
4
by: sjkothenbeutel | last post by:
I've been reading through quite a bit regarding this topic but am finding myself confused. Here is the scenario: I have a javascript class defined with methods whereas each has references to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.