473,805 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Migration" from IDREFS to an XML-Schema expression

Hi all,

here a little brain-twister (starting to spoil my weekend
if I do not find a solution ... ;-) )

What I want to do is to find a XML-Schema expression that builds
a grammar for the following XML document (fragment):

<grouping_docum ent>
<app_list>
<app id="id1">Progra m 1</app>
<app id="id2">Progra m 2</app>
<app id="id3">Progra m 3</app>
<!-- etc. -->
</app_list>

<grouping app_ref="id1 id3">
<!-- stuff for the referenced apps -->
</grouping>

<grouping app_ref="id2">
<!-- stuff for the referenced apps -->
</grouping>
</grouping_docume nt>
The <grouping_docum ent> describes some information that may be valid for
one or more applications. So it starts with a list of application definitions
whereas the key issue is that only the listed ids are allowed to appear as
values of attribute app_ref in the element <grouping>.

A valid DTD for this is

<!DOCTYPE grouping_docume nt [
<!ELEMENT grouping_docume nt ( app_list, grouping+ )>

<!ELEMENT app_list (app+)>
<!ELEMENT app (#PCDATA)>
<!ATTLIST app id ID #REQUIRED>

<!-- etc. -->

<!ELEMENT grouping (grouping_eleme nt+)>
<!ATTLIST grouping app_ref IDREFS #REQUIRED>

<!-- etc. -->
]>
But how to express these ID/IDREFS expressions in suitable in XML-Schema syntax?
(I do not have a problem with the standard key/keyref expressions. Where I'm
failing is the formulation of a list of references as value of a simple attribute.)

Here's what I have tried:

<xsd:complexTyp e name="GroupingT ype">
<xsd:sequence >
<xsd:element name="app_list" type="AppListTy pe">
<xsd:key name="AppKey">
<xsd:selector xpath="app"/>
<xsd:field xpath="@id"/>
</xsd:key>
</xsd:element>
<xsd:element name="grouping" type="GroupingT ype"/>
</xsd:sequence>
</xsd:complexType >

<!-- etc. -->

<complexType name="GroupingT ype">
<sequence>
<element name="grouping_ element">
<!-- etc. -->
</element>
</sequence>

<attribute name="id">
<simpleType name="AppIdList ">
<list itemType="strin g"/>
</simpleType>
<keyref name="aref" refer="jrn:AppK ey">
<field xpath="@app_id"/>
</keyref>
</attribute>
</complexType>
It's wrong, I know ...

But perhaps someone has a little tip for me?

Many thanks for your efforts!
Rabe
Jul 20 '05 #1
3 1985


Rabe wrote:

here a little brain-twister (starting to spoil my weekend
if I do not find a solution ... ;-) )

What I want to do is to find a XML-Schema expression that builds
a grammar for the following XML document (fragment):

<grouping_docum ent>
<app_list>
<app id="id1">Progra m 1</app>
<app id="id2">Progra m 2</app>
<app id="id3">Progra m 3</app>
<!-- etc. -->
</app_list>

<grouping app_ref="id1 id3">
<!-- stuff for the referenced apps -->
</grouping>

<grouping app_ref="id2">
<!-- stuff for the referenced apps -->
</grouping>
</grouping_docume nt>
The <grouping_docum ent> describes some information that may be valid for
one or more applications. So it starts with a list of application definitions
whereas the key issue is that only the listed ids are allowed to appear as
values of attribute app_ref in the element <grouping>.

A valid DTD for this is

<!DOCTYPE grouping_docume nt [
<!ELEMENT grouping_docume nt ( app_list, grouping+ )>

<!ELEMENT app_list (app+)>
<!ELEMENT app (#PCDATA)>
<!ATTLIST app id ID #REQUIRED>

<!-- etc. -->

<!ELEMENT grouping (grouping_eleme nt+)>
<!ATTLIST grouping app_ref IDREFS #REQUIRED>


But a W3C XML schema allows you to define attributes of type xs:ID as
well as of type xs:IDREFS, see
http://www.w3.org/TR/xmlschema-2/#built-in-datatypes
http://www.w3.org/TR/xmlschema-2/#ID
http://www.w3.org/TR/xmlschema-2/#IDREFS
so you can simply type your attributes as you have typed them in the DTD.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Hi,

thanks for your answer, I think it would (will!) work. (I know that
these types are valid in schema definitions too but I actually didn't
have the idea to use them ... :-)) )

But nevertheless there must be a solution to express ID/IDREFS in schema
syntax too, don't you think so?

As far as I know ID declarations bring up the problem that they are
global all over the document. So if I have a lot of ID declarations in
different elements how can I be sure that I'm referencing always the
right type of id?

When I expand my example with a list

<resource_lis t>
<resource id="res_id1"/>
<resource id="res_id2"/>
<resource id="res_id3"/>
</resource_list>

I will be able to reference a pretended application "res_id1" e.g.

<grouping app_ref="id1 res_id1">
<!-- stuff for the referenced apps -->
</grouping>

which is syntactically correct but semantically nonsense ...

Hmm ...

But your tip helped me a lot - I was already thinking about changing the
structure of my instance document ...

Bye Rabe

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3


R. B. wrote:

thanks for your answer, I think it would (will!) work. (I know that
these types are valid in schema definitions too but I actually didn't
have the idea to use them ... :-)) )

But nevertheless there must be a solution to express ID/IDREFS in schema
syntax too, don't you think so?


I told you to use the xs:ID and xs:IDREFS types, those are schema types,
so I am not sure why you ask for schema syntax, if you use
<xs:attribute name="id" type="xs:ID" />
then that is schema syntax and that is all I suggested to do.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #4

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

Similar topics

5
2998
by: Phil Powell | last post by:
I'm sorry but I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or...
36
6414
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but something I'll need in this case is some experience-based set of rules about how to use python in this context. For example... is defining readonly attributes in classes worth the hassle ? Does duck-typing scale well in complex
1
18740
by: Amol | last post by:
Hi, I want to fetch some values from a XML file, using a java program. I want to retrieve value of path tag for e.g<path>some path</path> tag.(Marked with **** in the below XML file Example) ============= My XML File ============
99
6257
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a small or mid-sized business. http://groups-beta.google.com/group/microsoft.public.msdn.general/browse_thread/thread/9d7e8f9a00c1c7da/459ca99eb0e7c328?q=%22Proposed+MSDN+subscription+changes%22&rnum=1#459ca99eb0e7c328 Damn! To be that...
24
7669
by: Hardy | last post by:
I'm pretty new in this field. when reading some 70x material, I met with this term but cannot catch its accurate meaning. who can help me? thanks in advance:)~
2
2780
by: Gustavo Randich | last post by:
Hello, (Using DB2/LINUX 8.2.0) After compiling the STRIP migration UDF (found at http://www-106.ibm.com/developerworks/db2/library/samples/db2/0205udfs/), if I try to execute: values char(STRIP('0000345.50','L','0'),20) @
2
1449
by: pankaj_wolfhunter | last post by:
Greetings, Can someone recommend me some online redbooks or any link regarding "Migration from Sybase to Sql Server"? Any feedback will be appreciated TIA
18
1500
by: Doug H | last post by:
Ran across this (requires Firefox): http://www.pugscode.org/osdc/vb.xul Done by the developer of a new perl6 runtime called pugs. Information about Visual Basic 9 is here, if you haven't already read about it: http://msdn.microsoft.com/vbasic/future/default.aspx
13
2313
by: Kobee | last post by:
Hi, I'm having a few issues adapting to new 2.0 "website" project vs. the old 1.1 "web application". One of the major issues I'm having is with the notion of namespaces. Using the old way, I could add a directory to my project (say, "Controls"), then add a user control to that directory. From an .aspx I could then import the namespace ("using .Controls";), and then reference that control. With the 2.0 way of doing things, if I add a...
1
1437
by: Ilias Lazaridis | last post by:
If I understood things right, setuptools extends the functionality of distutils Thus replacing within a setup.py: from distutils.core import setup with try:
0
9718
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
10613
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10368
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
10107
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
9186
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...
1
7649
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
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
5544
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.