472,330 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 software developers and data experts.

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 3154
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...
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...
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...
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...
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...
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...
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...
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...
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.