473,544 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

easy xsd question?

KJ
In an Xml schema: can an element have children which come from another
namespace?

For example, can this be declared in the schema:

<top>
<anotherNamespa ce:a>
<aThirdNamespac e:b>
Hello World
</aThirdNamespace :b>
</anotherNamespac e:a>
</top>

How might the xsd look for this?

Aug 12 '05 #1
5 1166
Yes, but you need to have a schema document for each namespace that you
use.

If your "top" element is not in a namespace, your main schema document
would not have a target namespace. It would look roughly like this:

<xs:schema xmlns:anotherNa mespace="foo" ...>
<xs:import namespace="anot herNamespace"
schemaLocation= ...
<xs:element name="top">
<xs:complexType >
<xs:sequence>
<xs:element ref="anotherNam espace:a"/>
.....

The schema document that declares "a" would import the third namespace,
looking roughly like this:

<xs:schema targetNamespace ="foo"
xmlns:anotherNa mespace="foo"
xmlns:aThirdNam espace="bar" ...
<xs:import namespace="aThi rdNamespace"
schemaLocation= ...
<xs:element name="a">
<xs:complexType >
<xs:sequence>
<xs:element ref="aThirdName space:b"/>
.....

And the third schema document would look like:

<xs:schema targetNamespace ="bar"
xmlns:aThirdNam espace="bar" ...
<xs:element name="b">
.....

etc.

Hope that helps,
Priscilla

----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Aug 12 '05 #2
KJ
Thank you. Would you please entertain a further question? I hope I can
word this so it makes sense.

Do the nodes of instance documents of such a schema have to obey the
sequence and other rules of their respective schemas, in addition to
obeying the rules of the schema in which they are included? (Are
parsers smart enough to recognize this kind of thing?)

And, can an schema that imports nodes from change the restrictions set
forth by the imported schema, for example, by reordering sequences, and
so forth?

-KJ

Aug 12 '05 #3
Hi,

I'm not sure I'm entirely following your question. Any given element
would be declared in only one of the schema documents, so its contents
would have to follow the rules that are specified in that one
declaration.

About your second question, No, the importing schema cannot reorder
sequences in types that are in the imported schema document. But you
can create new types in the importing schema document that combine
elements from the other (imported) namespace in different ways.

Hope that helps,
Priscilla
----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Aug 13 '05 #4
KJ
That was pretty much what I was trying to ask. Thanks for answering.
What I need to do now is just try out some of these scenarios to see
how it all works.

-KJ

Aug 15 '05 #5
KJ wrote:
In an Xml schema: can an element have children which come from another
namespace?


Yes, this was one of the original (long-forgotten and never-implemented)
reasons for namspaces in the first place -- to be able to import a subset
of some other DTD or Schema to save you having to reinvent the wheel.

For example, "let me use Lists the way DocBook does them" or "give me
section and heading declarations the way TEI does them".

Increasing modularisation may one day make this possible :-) For now,
it's just as Priscilla describes it.

///Peter
--
sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
&;top"
Aug 16 '05 #6

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

Similar topics

1
2210
by: rdsteph | last post by:
I am having a lot of fun using the pyGoogle module ( http://pygoogle.sourceforge.net/ ) that uses the Google API. It is about as easy to use as I can imagine, and it is a lot nicer than using my old HTMl screen scraping habits. My online CGI program Ask Merlin at www.awaretek.com/askmerlin.html is an example. Currently, the program takes...
0
1363
by: | last post by:
I don't know SQL at all, but I have a problem now because I must use SQL in my PHP scripts. So please help me! I have 2 tables: id | name ----------- 1 | thing1 2 | thing2 3 | thing3 4 | thing4
5
1521
by: LedZep | last post by:
What up, All I need to do is enter a last name in a text box, query a MSAccess database and display the name with the corresponding columns. This is no problem, but when there are more than one records with the same last name, I need to click a command button to display the next record with that name. I cant find it in any of my books and...
1
4923
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real pain to work with if you just want to throw some values in a grid and edit them with a textbox. i don't want to persist anything in a database, i...
13
1466
by: Ghislain Tanguay | last post by:
I have a compiled vb.net app and I want to give the user a choice to launch it from the start line command and pass it a parameter or not. How can I do that in my code? Is it possible? Ex. : MyApp.exe "Go"
1
1474
by: melanieab | last post by:
Hi, If there's a textbox and the text entered is longer than what's visible (the textbox length), how do you make it so that the beginning chunk of text is visible (instead of the last part of it)? Thanks again!!! Mel
23
2397
by: **Developer** | last post by:
Is there an easy way to copies all files in a directory into another directory? What about coping subdirectories too? Thanks in advance for any info
6
2282
by: Martin Bootsma | last post by:
I have a C question, which looks very easy, but no one here seems to know an easy answer. I have a function "powell" (from Numerical Recipes) which takes an argument of the type "double (*f)(float)" But I want to be able to pass a
27
2264
by: smnoff | last post by:
How does( or should user use) strncpy() to allocate enough memory space for the destination string, s1? I guess I am having trouble using strncpy as it seems to be giving me errors. And just as well, I don't know the value of n until the program runs, so it needs to be dynamically allocated. Then again I hard coded n to be number like3...
9
1884
by: rynTAU | last post by:
This is an easy question, I'm sure but I can't seem to figure it out. I'm trying to use the number_format() function to remove all decimal places from a number. $num = number_format($num, 0, '.', ''); So if I have 23.34567 I want 23, and 45.8789 will return with 45.
0
7414
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7359
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...
0
7598
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
5895
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...
1
5288
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4905
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...
0
3398
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
651
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...

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.