473,246 Members | 1,353 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,246 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 1947


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
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.