473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

"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_document>
<app_list>
<app id="id1">Program 1</app>
<app id="id2">Program 2</app>
<app id="id3">Program 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_document>
The <grouping_document> 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_document [
<!ELEMENT grouping_document ( app_list, grouping+ )>

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

<!-- etc. -->

<!ELEMENT grouping (grouping_element+)>
<!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:complexType name="GroupingType">
<xsd:sequence>
<xsd:element name="app_list" type="AppListType">
<xsd:key name="AppKey">
<xsd:selector xpath="app"/>
<xsd:field xpath="@id"/>
</xsd:key>
</xsd:element>
<xsd:element name="grouping" type="GroupingType"/>
</xsd:sequence>
</xsd:complexType>

<!-- etc. -->

<complexType name="GroupingType">
<sequence>
<element name="grouping_element">
<!-- etc. -->
</element>
</sequence>

<attribute name="id">
<simpleType name="AppIdList">
<list itemType="string"/>
</simpleType>
<keyref name="aref" refer="jrn:AppKey">
<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 1951


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_document>
<app_list>
<app id="id1">Program 1</app>
<app id="id2">Program 2</app>
<app id="id3">Program 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_document>
The <grouping_document> 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_document [
<!ELEMENT grouping_document ( app_list, grouping+ )>

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

<!-- etc. -->

<!ELEMENT grouping (grouping_element+)>
<!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_list>
<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
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...
36
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...
1
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) ...
99
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...
24
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
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...
2
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
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...
13
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...
1
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.