473,614 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Allowing specific elements from another namespace...

I have a document type which I'm developing and working with, which is
currently defined in a DTD, mainly because I still haven't really
learned to use schemas. In this document type I need to specify that
some specific elements may have children which are XHTML %Flow;
elements. It isn't valid for these elements to contain arbitrary
XHTML, and it isn't valid for other elements in my language to have
any XHTML children.

I presume I can't do this in a DTD (except by including the XHTML DTD
into mine, which would mean that I would end up with the whole of
XHTML in my namespace, which isn't what I want). But how would I go
about doing it in a schema?
Jun 27 '08 #1
2 1562
Simon Brooke wrote:
I have a document type which I'm developing and working with, which is
currently defined in a DTD, mainly because I still haven't really
learned to use schemas. In this document type I need to specify that
some specific elements may have children which are XHTML %Flow;
elements. It isn't valid for these elements to contain arbitrary
XHTML, and it isn't valid for other elements in my language to have
any XHTML children.

I presume I can't do this in a DTD (except by including the XHTML DTD
into mine, which would mean that I would end up with the whole of
XHTML in my namespace, which isn't what I want). But how would I go
about doing it in a schema?
The W3C XML schema language has an xs:any element where you can specify
a namespace so you can allow any element in the XHTML namespace. You
can't specify a certain type however so I don't know how you could
restrict the element children to be of type flow. It might be best to
import a schema for XHTML and then allow an XHTML div element as the
child e.g.
<xs:element ref="xhtml:div"/>
that way you can then have the other elements inside the div element.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
I presume I can't do this in a DTD

DTDs are not namespace aware. You could allow specific elements with a
particular prefix, and try to set up required/default declarations for
that prefix to be the intended namespace... but in general if you're
using namespaces (and these days you should be), you should move to XML
Schema and handle them properly.

In schemas, allowing specific elements in another namespace should be
straightforward : you should be able to bind a prefix to that namespace
and use the appropriate prefixed QNames in your schema's description of
legal contents just as you would reference elements within the same
namespace. There should be examples of this on the web in various schema
tutorials; I haven't gone hunting for one recently so I don't have a
good pointer to give you other than the Schema recommendation (which is
not easy reading).

Jun 27 '08 #3

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

Similar topics

0
4221
by: C. M. Sperberg-McQueen | last post by:
wooks (wookiz@hotmail.com) wrote: > <?xml version='1.0'?> > <userlogin xmlns="urn:faster:userlogin" > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> > <login>mick</login> > <password>brown</password> > </userlogin> > Above is my schema instance.
2
3926
by: wooks | last post by:
I want to apply 2 changes to the following xml <ROOTSTUB app="appname"/> 1. change the app attribute to an element. 2. put the ROOTSTUB element into a namespace that is passed as a global parameter at run time. so I want
8
1966
by: Hugh Sparks | last post by:
When processing an xml document that contains elements such as: <element xmlns="goop"/> ... <element xmlns="gleep"/> I want to create two xsl stylesheet templates: one that matches the elements that contain the namespace declaration for "goop" and one that matches the elements that contain the namespace declaration for "gleep".
2
1413
by: Brett Gerhardi | last post by:
Hi all, I'm trying to something that I'm sure must be possible within the schema language but I cannot seem to work it out. Briefly, I am defining a multi-tiered base structure - each tier has its own complextype defined with a base CT having the structure that others should follow. At the leaf ends of some areas I want to restrict the type of elements that are defined in restriction extended types but cannot find the correct way to...
12
3482
by: Lawrence Oluyede | last post by:
I've some problems with filtering out a specific element by the following xml snippet (is part of a bigger xml document): <entry> <link href="http://www.blogger.com/atom/5281182/108809850419059234" rel="service.edit" title="test" type="application/x.atom+xml"/> <author> <name>Lawrence</name> </author> <issued>2004-06-24T19:34:04+02:00</issued>
1
1116
by: cmrchs | last post by:
Hi, is there an easy way to provide all elements in an xml-document of a namespace-prefix. Example of source file : <book> <title>Alaska</title> </book> convert to :
22
2273
by: spam.noam | last post by:
Hello, I discovered that I needed a small change to the Python grammar. I would like to hear what you think about it. In two lines: Currently, the expression "x" is a syntax error. I suggest that it will be evaluated like "x", just as "x" is evaluated like "x" right now.
4
6277
by: newbie120 | last post by:
Hi all maybe its just been a long day, but i have a question about call access modifiers in C#. Consider the following code. namespace Application { private class Class1 { int i;
22
2315
by: Christopher Nelson | last post by:
I have a little menu system which essentially takes HTML like: <div id='foo'></div> and retrieves foo.shtml from the server and inserts it inside the <div>. But sometimes I'd like foo.shtml to look like: <script language='JavaScript'> ...do something AJAX-y </script>
0
8197
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
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
8287
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
8443
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
7114
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
5548
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
4136
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2573
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
0
1438
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.