Old dog trying to learn some new tricks.
Tuesday, 29 August 2017 · 4 messages
DD
Dave Day29 Aug 2017 01:02 #
Greetings BaseX list,
I've got some very basic questions I was hoping I could get the answers to on this list. Questions really break down into two categories. My background is strictly on IBM mainframes, so please bear with me.
1)Some XML schema questions, and
2)Questions regarding how to configure/use BaseX for what I want to do.
XML schema. I've got a record definition created by IBM that changes somewhat depending upon the release of the system. I want to create XML schema for each release dependent definition, and then make that definition available to BaseX. I thought using namespaces was the way to go, but now am not sure.
What I was hoping to do was to connect to a running BaseX, and send the schema definitions that would be used to validate the XML. In reading doc, I see it is possible to create namespaces and use them, but the format has to be either a URL or a URN. Is it possible to create a URN for a namespace on the fly, and then tell the code later on which namespace to use?
Regards,
-- Dave Day
KS
Kendall Shaw29 Aug 2017 02:11 #
Can you elaborate on what you were imagining doing with namespaces? An XML namespace is referred to by it’s URI. If you created one, I don’t know what it would mean to tell the code later on which to use.
Do you mean a namespace prefix?
Kendall
Quoted text · basex-talk-bounces at mailman.uni-konstanz.de on behalf of Dave Day · 1 line
On 8/28/17, 2:02 PM, "basex-talk-bounces at mailman.uni-konstanz.de on behalf of Dave Day" <basex-talk-bounces at mailman.uni-konstanz.de on behalf of David.Day at duke-software.com> wrote:
Greetings BaseX list,
I've got some very basic questions I was hoping I could get the answers to on this list. Questions really break down into two categories. My background is strictly on IBM mainframes, so please bear with me.
1)Some XML schema questions, and
2)Questions regarding how to configure/use BaseX for what I want to do.
XML schema. I've got a record definition created by IBM that changes somewhat depending upon the release of the system. I want to create XML schema for each release dependent definition, and then make that definition available to BaseX. I thought using namespaces was the way to go, but now am not sure.
What I was hoping to do was to connect to a running BaseX, and send the schema definitions that would be used to validate the XML. In reading doc, I see it is possible to create namespaces and use them, but the format has to be either a URL or a URN. Is it possible to create a URN for a namespace on the fly, and then tell the code later on which namespace to use?
Regards,
-- Dave Day
LQ
Quoted text · Dave Day · 2 lines
On Mon, 2017-08-28 at 16:02 -0500, Dave Day wrote: >
[...]
Quoted text · Dave Day · 10 lines
> What I was hoping to do was to connect to a running BaseX, and > send > the schema definitions that would be used to validate the XML. In > reading doc, I see it is possible to create namespaces and use them, > but > the format has to be either a URL or a URN. Is it possible to create > a > URN for a namespace on the fly, and then tell the code later on > which > namespace to use?
I think really you are wanting to validate against a particular schema. This is entirely unrelated to which namespace URI is used to identify elements in the document. You can have multiple XML Schema Documents (xsd) for validating XML documents whose elements are "in" the same namespace.
A namespace in XML is nothing more or less than a URI used as a name. They don't actually "do" anything :)
http://docs.basex.org/wiki/Validation_Module#XML_Schema_Validation has an example that might help.
Liam
--
Liam Quin, W3C, http://www.w3.org/People/Quin/
Staff contact for Verifiable Claims WG, XQuery WG
Web slave for http://www.fromoldbooks.org/
AH
Quoted text · Dave Day · 17 lines
> On 28. Aug 2017, at 23:02, Dave Day <David.Day at duke-software.com> wrote: > > Greetings BaseX list, > > I've got some very basic questions I was hoping I could get the answers to on this list. Questions really break down into two categories. My background is strictly on IBM mainframes, so please bear with me. > > 1)Some XML schema questions, and > > 2)Questions regarding how to configure/use BaseX for what I want to do. > > XML schema. I've got a record definition created by IBM that changes somewhat depending upon the release of the system. I want to create XML schema for each release dependent definition, and then make that definition available to BaseX. I thought using namespaces was the way to go, but now am not sure. > > What I was hoping to do was to connect to a running BaseX, and send the schema definitions that would be used to validate the XML. In reading doc, I see it is possible to create namespaces and use them, but the format has to be either a URL or a URN. Is it possible to create a URN for a namespace on the fly, and then tell the code later on which namespace to use? > > Regards, > > -- Dave Day
Hi Dave,
is it possible to see one of those 'record definitions created by IBM’ as an example?
I guess, what you would want to generate given a ‘record definition’ is twofold:
- Multiple XML representations of actual data that corresponds to the ‘record definition’.
- A schema definition to validate instances of those XML representions.
Example:
A ‘record definition’:
Mainframe defines an event.
An event has a start and end time as integers.
Each event has an id.
I guess such a definition is probably burried in some kind of specification or even source code, but can be extracted somehow. So you finally get something from which you would be able to automatically generate a schema definition. This generated schema definition could look like this (in RELAX NG [1]):
[mainframe.rng]
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<ref name="mainframe"/>
</start>
<define name="mainframe">
<element name="mainframe">
<zeroOrMore>
<ref name="event"/>
</zeroOrMore>
</element>
</define>
<define name="event">
<element name="event">
<ref name="event.attlist"/>
</element>
</define>
<define name="event.attlist">
<ref name="id.attrib"/>
<ref name="start.attrib"/>
<ref name="end.attrib"/>
</define>
<define name="id.attrib">
<attribute name="id">
<ref name="id.datatype"/>
</attribute>
</define>
<define name="start.attrib">
<attribute name="start">
<ref name="integer.datatype"/>
</attribute>
</define>
<define name="end.attrib">
<attribute name="end">
<ref name="integer.datatype"/>
</attribute>
</define>
<define name="id.datatype">
<data type="ID"/>
</define>
<define name="integer.datatype">
<data type="integer"/>
</define>
</grammar>Now events occur on the mainframe and your code produces event XML instances, such as:
[event-1.xml]
<mainframe>
<event start="1000" end="1700" id="e1"/>
<event start="3300" end="4000" id="e2"/>
</mainframe>To ‘validate’ those XML instances you use a software such as jing [2].
[terminal]
$ jing mainframe.rng event-1.xmlNo BaseX involved so far.
If you need to store a lot of those XML documents, it may, of course, be handy to store them in BaseX. To validate them against the schema you can use the Validation Module [3].
[validate.xq]
validate:rng-report('event-1.xml', 'mainframe.rng')Am I on the right track of what you are trying to achieve?
Kind regards,
Alex
[1] http://relaxng.org
[2] http://relaxng.org/#validators
[3] http://docs.basex.org/wiki/Validation_Module#RelaxNG_Validation
Written for BaseX 8.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery