473,320 Members | 1,978 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.

Mixing schemas


I have a schema defining the input of a particular application. Let's
refer to the namespace for my schema by the prefix "my:". Now the need
has arisen to annotate such input documents with foreign attributes
and tags (which my application is to ignore). I see no problems with
attributes, but there are many ways to do it for elements.

One way is to use xs:any at the end of every complexType, thereby
allowing foreign elements at the end.

Another is to introduce a new element <my:appinfosimilar to
<xs:appinfo>, letting any foreign elements appear within it, but
forcing the <my:appinfoelement to be at the beginning of my
complexTypes, where I already have a <my:description>.

A third is to extend <my:descriptionto accept not only text, as
today, but arbitrary foreign elements.

A fourth way would be to put <xs:any ... maxOccurs="unbounded">
between all children in my complexType, allowing foreign elements
everywhere.

How is this usually done? Is there a best way? (I want minimum impact
on my own schema, and maximum usability for the user, and those two
goals of course are in conflict.)

/Arndt Jonasson

Mar 21 '07 #1
5 1713
Hi,

The best solution I believe is to use NVDL - namesapce based
validation and dispatching language. This allows to define fragments
of the document to be validated with different schemas, thus you do
not need to make any changes to your schema file.
For instance in your case you can specify that all the the content in
your my namespace to be put together and validated with the my.xsd
schema while content from other namesapces to be allowed. Here it is a
sample NVDL script for that:

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
startMode="init">
<mode name="init">
<namespace ns="http://my">
<validate schema="my.xsd" useMode="my"/>
</namespace>
</mode>
<mode name="my">
<namespace ns="http://my"><attach/></namespace>
<anyNamespace><allow/></anyNamespace>
</mode>
</rules>

There are a few implementations already for NVDL see www.nvdl.org.
>From oNVDL (http://www.oxygenxml.com/onvdl.html) you can use XML
Schema, Relax NG or Schematron as schema languages.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
On Mar 21, 3:09 pm, "Arndt Jonasson" <arndt.jonas...@gmail.comwrote:
I have a schema defining the input of a particular application. Let's
refer to the namespace for my schema by the prefix "my:". Now the need
has arisen to annotate such input documents with foreign attributes
and tags (which my application is to ignore). I see no problems with
attributes, but there are many ways to do it for elements.

One way is to use xs:any at the end of every complexType, thereby
allowing foreign elements at the end.

Another is to introduce a new element <my:appinfosimilar to
<xs:appinfo>, letting any foreign elements appear within it, but
forcing the <my:appinfoelement to be at the beginning of my
complexTypes, where I already have a <my:description>.

A third is to extend <my:descriptionto accept not only text, as
today, but arbitrary foreign elements.

A fourth way would be to put <xs:any ... maxOccurs="unbounded">
between all children in my complexType, allowing foreign elements
everywhere.

How is this usually done? Is there a best way? (I want minimum impact
on my own schema, and maximum usability for the user, and those two
goals of course are in conflict.)

/Arndt Jonasson

Mar 22 '07 #2
On Mar 22, 9:04 am, "George Bina" <geo...@oxygenxml.comwrote:
The best solution I believe is to use NVDL - namesapce based
validation and dispatching language. This allows to define fragments
of the document to be validated with different schemas, thus you do
not need to make any changes to your schema file.
For instance in your case you can specify that all the the content in
your my namespace to be put together and validated with the my.xsd
schema while content from other namesapces to be allowed.
Thank you. NVDL sounds interesting, but it seems like a more long-term
option to me.

Validation is only the first (logical) step in my application. When
the input has been deemed valid, the elements are processed, and I
suppose that with NVDL, I would still need to recognize and ignore the
foreign parts.

Is NVDL in common use yet? If I go with my original idea of extending
the application to allow but ignore foreign namespaces in certain
parts of the document, would a user feel constrained if the foreign
parts can only occur, say, as the first child elements of each
element?

Mar 22 '07 #3
You can pass the document before getting it to your application
through an XSLT transformation that filters out the foreign content:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[namespace-uri()!='http://test']">
<xsl:apply-templates select="node() | @*"/>
</xsl:template>
<xsl:template match="@*[namespace-uri()!='http://test' and namespace-
uri()!='']"/>
</xsl:stylesheet>

Thus your application remains unchanged.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
On Mar 22, 11:03 am, "Arndt Jonasson" <arndt.jonas...@gmail.com>
wrote:
On Mar 22, 9:04 am, "George Bina" <geo...@oxygenxml.comwrote:
The best solution I believe is to use NVDL - namesapce based
validation and dispatching language. This allows to define fragments
of the document to be validated with different schemas, thus you do
not need to make any changes to your schema file.
For instance in your case you can specify that all the the content in
your my namespace to be put together and validated with the my.xsd
schema while content from other namesapces to be allowed.

Thank you. NVDL sounds interesting, but it seems like a more long-term
option to me.

Validation is only the first (logical) step in my application. When
the input has been deemed valid, the elements are processed, and I
suppose that with NVDL, I would still need to recognize and ignore the
foreign parts.

Is NVDL in common use yet? If I go with my original idea of extending
the application to allow but ignore foreign namespaces in certain
parts of the document, would a user feel constrained if the foreign
parts can only occur, say, as the first child elements of each
element?

Mar 22 '07 #4
Just an update to the NVDL script, the above example did not accept
foreign attributes. So a complete and tested example is below,
assuming the namespace we are interested in is http://test

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
startMode="init">
<mode name="init">
<namespace match="elements" ns="http://test">
<validate schema="test.xsd" useMode="my"/>
</namespace>
</mode>
<mode name="my">
<namespace ns="http://test" match="attributes elements"><attach/></
namespace>
<namespace ns="" match="attributes"><attach/></namespace>
<anyNamespace match="attributes elements"><unwrap/></anyNamespace>
</mode>
</rules>

It ignores (unwrap) elements and attributes from foreign namespaces
and keeps all content that is in the http://test namespace plus
attributes in no namespace.

NVDL is new but it is already working. You have 3 implementations to
choose from and oXygen XML editor provides all the support you need to
develop and test your NVDL scripts or to edit and validate files
against NVDL scripts.

Put NVDL on validation and you solved the validation then run the
document through a simple XSLT transformation as in my previous
example and you have both your schema and your application unchanged.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On Mar 22, 11:41 am, "George Bina" <geo...@oxygenxml.comwrote:
You can pass the document before getting it to your application
through an XSLT transformation that filters out the foreign content:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[namespace-uri()!='http://test']">
<xsl:apply-templates select="node() | @*"/>
</xsl:template>
<xsl:template match="@*[namespace-uri()!='http://test'and namespace-
uri()!='']"/>
</xsl:stylesheet>

Thus your application remains unchanged.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debuggerhttp://www.oxygenxml.com

On Mar 22, 11:03 am, "Arndt Jonasson" <arndt.jonas...@gmail.com>
wrote:
On Mar 22, 9:04 am, "George Bina" <geo...@oxygenxml.comwrote:
The best solution I believe is to use NVDL - namesapce based
validation and dispatching language. This allows to define fragments
of the document to be validated with different schemas, thus you do
not need to make any changes to your schema file.
For instance in your case you can specify that all the the content in
your my namespace to be put together and validated with the my.xsd
schema while content from other namesapces to be allowed.
Thank you. NVDL sounds interesting, but it seems like a more long-term
option to me.
Validation is only the first (logical) step in my application. When
the input has been deemed valid, the elements are processed, and I
suppose that with NVDL, I would still need to recognize and ignore the
foreign parts.
Is NVDL in common use yet? If I go with my original idea of extending
the application to allow but ignore foreign namespaces in certain
parts of the document, would a user feel constrained if the foreign
parts can only occur, say, as the first child elements of each
element?

Mar 22 '07 #5
On Mar 22, 11:19 am, "George Bina" <geo...@oxygenxml.comwrote:
NVDL is new but it is already working. You have 3 implementations to
choose from and oXygen XML editor provides all the support you need to
develop and test your NVDL scripts or to edit and validate files
against NVDL scripts.

Put NVDL on validation and you solved the validation then run the
document through a simple XSLT transformation as in my previous
example and you have both your schema and your application unchanged.
Thank you. The problem for me is that my environment is restricted
from an XML point of view - the language is Erlang, and the system
contains a schema parser/validator and XPath and not much more. Not
xslt, for example. So I do have to build knowledge of foreign parts
into my code (putting xsltproc in the pipeline is an option, of
course, but somewhat awkward). I suppose my position is somewhat
unusual, and what people usually do with foreign parts is just filter
them away first.

Mar 23 '07 #6

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

Similar topics

0
by: kyancy | last post by:
Hello All. We have several XML schemas to describe common component document parts. We then create new XML schemas as necessary that use "xsd:import schemaLocation=whateverLocation.." to include...
30
by: btober | last post by:
Whenever I create a temporary table, with something like CREATE TEMPORARY TABLE temptable1 AS SELECT * FROM paid.ad_hoc_query; New schemas appear, with names like "pg_temp_1". I guess the...
7
by: Roderick A. Anderson | last post by:
I'm looking for some input on a configuration I'm implementing. The long term goal is to providing hosting for companies and organizations with a basic/generic set of applications that use...
4
by: anonymous | last post by:
When I use the schema collection to apply many schemas to one XML instance document, I get an error if I do not qualify every element with the appropriate namespace. Both the W3C site and this...
2
by: John Jenkins | last post by:
Hi, I have a lot of schemas to load into a schema collection. I load them in by reading each one into a XMLTextReader from disk and add them into a schema collection. I have a couple of issues to...
1
by: CSN | last post by:
I have two machines between which I exchange dumps a lot. On the first (Windows/cygwin), pgsql was set up with "Administrator" as the main superuser - who owns all schemas in template0 and...
6
by: Dennis Gearon | last post by:
This post is as much about getting some questions answered as leaving the following definitions in the archives for the next person. After a quick perview of the web, I came up with the...
3
by: Sami Marzouki | last post by:
Hi, What I'm trying to do is: - To write a Web.config with custom sections. (Done) - To write a xsd schema for this custom sections.(Done) - Tell the Web.config to take the two schemas. When...
28
by: ziman137 | last post by:
Hello all, I have a question and am seeking for some advice. I am currently working to implement an algorithmic library. Because the performance is the most important factor in later...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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...

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.