[ODD] Changing only <div>s in certain contexts

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[ODD] Changing only <div>s in certain contexts

Gioele Barabucci-2
Hello,

in ODD, how can I change the constraints of the <div> elements that
appear in a certain position (e.g., /TEI/text/body) while using the
default definition for all the other elements?

I could specify those constraints as a set of Schematron assertions, but
those would not be picked up by, for example, oXygen for the automatic
completion of element names and attribute values.

In RelaxNG one can give two different definitions of <div>: one for
those elements appearing in a certain production, and another for all
the others contexts. Can the same thing be done in ODD?

The use case for this request is that I would like <div>s in
/TEI/text/body to contain only few whitelisted elements, while allowing
<div> in other places (mainly the header) to be unconstrained.

Note: Element names and element definitions are separate entities in
RelaxNG; in ODD it looks like element names and their definitions cannot
be separated (I suppose this has to do with DTD support). Probably this
means that what I am looking for cannot be done, but I think it is worth
asking anyway.

Regards,

--
Gioele Barabucci <[hidden email]>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

Lou Burnard-6
If I understand you correctly, you're asking for the ability to define a
context-dependent content model, e.g. such that <p> as a descendant of
<teiHeader> might have a different content model from <p> as a
descendant of <text>. (Your mail talks about <div> as a child of
<teiHeader> but that's not legal at all, so I am assuming you meant <p> !)

This is certainly  something we have discussed as a useful addition to
the ODD language, but it hasn't been implemented yet. The syntax
proposed was to add a @context attribute to the <content> element, but
this hasn't been done yet. Processing that into  RelaxNG wouldn't be
hard, since as you suggest, there's at least one nice implementation
strategy; for DTD this is just impossible; for W3C Schema, I don't know,
but since we generate our W3C schemas from Relaxng that may not matter.

The TEI Simple ODD includes a set of Schematron rules designed to
prevent child elements which are permitted in the Header from appearing
in the <body>. They appear as <constraintSpec>s, like other Schematron
rules, and are processed as such by the current stylesheets, so that
oXygen will certainly flag any such elements as errors: I am not sure
what you mean by "automatic completion of element names" in this context.



On 22/06/16 17:14, Gioele Barabucci wrote:

> Hello,
>
> in ODD, how can I change the constraints of the <div> elements that
> appear in a certain position (e.g., /TEI/text/body) while using the
> default definition for all the other elements?
>
> I could specify those constraints as a set of Schematron assertions,
> but those would not be picked up by, for example, oXygen for the
> automatic completion of element names and attribute values.
>
> In RelaxNG one can give two different definitions of <div>: one for
> those elements appearing in a certain production, and another for all
> the others contexts. Can the same thing be done in ODD?
>
> The use case for this request is that I would like <div>s in
> /TEI/text/body to contain only few whitelisted elements, while
> allowing <div> in other places (mainly the header) to be unconstrained.
>
> Note: Element names and element definitions are separate entities in
> RelaxNG; in ODD it looks like element names and their definitions
> cannot be separated (I suppose this has to do with DTD support).
> Probably this means that what I am looking for cannot be done, but I
> think it is worth asking anyway.
>
> Regards,
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

Imsieke, Gerrit, le-tex
In reply to this post by Gioele Barabucci-2
Hi Gioele,

Neither an ODD nor a Schematron approach: You can use a second RNG
schema. Here is a sample schema (that also serves as a blog post about
this approach):
https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng

I tried to prescribe div/@type attributes in such a way that the types
correspond to DocBook element names, and the grammar is (roughly) the
same as in DocBook. So you have parts or chapters in the body, prefaces
and dedications in the frontmatter, etc.

The nice thing is that you superimpose a bespoke grammar on an
off-the-shelf TEI schema. An actual grammar refining an unaltered base
schema, if that doesn’t sound compelling. You can’t do this with
Schematron so handily.

A sample document is here:
https://gist.github.com/gimsieke/44748c504783590ef906c7dc0c2e268b
If you open it in oXygen and add a type attribute to body/div, you will
be presented with a choice of part and chapter.
This is the good news.
The bad news is that there will be no other completion hints than those
from the epischema – unless you swap the xml-model PIs at the top, but
then you’ll only have the default TEI vocabulary as suggestions.
Maybe we can convince the oXygen people to restrict the autocomplete
options to the intersection of the choices that all referenced schemas
offer at a given location.

Gerrit

On 22.06.2016 18:14, Gioele Barabucci wrote:

> Hello,
>
> in ODD, how can I change the constraints of the <div> elements that
> appear in a certain position (e.g., /TEI/text/body) while using the
> default definition for all the other elements?
>
> I could specify those constraints as a set of Schematron assertions, but
> those would not be picked up by, for example, oXygen for the automatic
> completion of element names and attribute values.
>
> In RelaxNG one can give two different definitions of <div>: one for
> those elements appearing in a certain production, and another for all
> the others contexts. Can the same thing be done in ODD?
>
> The use case for this request is that I would like <div>s in
> /TEI/text/body to contain only few whitelisted elements, while allowing
> <div> in other places (mainly the header) to be unconstrained.
>
> Note: Element names and element definitions are separate entities in
> RelaxNG; in ODD it looks like element names and their definitions cannot
> be separated (I suppose this has to do with DTD support). Probably this
> means that what I am looking for cannot be done, but I think it is worth
> asking anyway.
>
> Regards,
>

--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
[hidden email], http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

George Bina
What about using a schema that combines the two schemas, like

<grammar
     xmlns="http://relaxng.org/ns/structure/1.0"
     xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
     datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
     <start>
         <choice>
          <externalRef
href="http://www.tei-c.org/Vault/P5/1.7.0/xml/tei/custom/schema/relaxng/tei_all.rng"/>
          <externalRef
href="https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng"/>
         </choice>
     </start>
</grammar>

Note that you need to disable the ID/IDREF checking from
Options->Preferences -- XML / XML Parser / RELAX NG because there are
conflicting IDs defined.

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

On 24/06/16 02:30, Imsieke, Gerrit, le-tex wrote:

> Hi Gioele,
>
> Neither an ODD nor a Schematron approach: You can use a second RNG
> schema. Here is a sample schema (that also serves as a blog post about
> this approach):
> https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng
>
> I tried to prescribe div/@type attributes in such a way that the types
> correspond to DocBook element names, and the grammar is (roughly) the
> same as in DocBook. So you have parts or chapters in the body, prefaces
> and dedications in the frontmatter, etc.
>
> The nice thing is that you superimpose a bespoke grammar on an
> off-the-shelf TEI schema. An actual grammar refining an unaltered base
> schema, if that doesn’t sound compelling. You can’t do this with
> Schematron so handily.
>
> A sample document is here:
> https://gist.github.com/gimsieke/44748c504783590ef906c7dc0c2e268b
> If you open it in oXygen and add a type attribute to body/div, you will
> be presented with a choice of part and chapter.
> This is the good news.
> The bad news is that there will be no other completion hints than those
> from the epischema – unless you swap the xml-model PIs at the top, but
> then you’ll only have the default TEI vocabulary as suggestions.
> Maybe we can convince the oXygen people to restrict the autocomplete
> options to the intersection of the choices that all referenced schemas
> offer at a given location.
>
> Gerrit
>
> On 22.06.2016 18:14, Gioele Barabucci wrote:
>> Hello,
>>
>> in ODD, how can I change the constraints of the <div> elements that
>> appear in a certain position (e.g., /TEI/text/body) while using the
>> default definition for all the other elements?
>>
>> I could specify those constraints as a set of Schematron assertions, but
>> those would not be picked up by, for example, oXygen for the automatic
>> completion of element names and attribute values.
>>
>> In RelaxNG one can give two different definitions of <div>: one for
>> those elements appearing in a certain production, and another for all
>> the others contexts. Can the same thing be done in ODD?
>>
>> The use case for this request is that I would like <div>s in
>> /TEI/text/body to contain only few whitelisted elements, while allowing
>> <div> in other places (mainly the header) to be unconstrained.
>>
>> Note: Element names and element definitions are separate entities in
>> RelaxNG; in ODD it looks like element names and their definitions cannot
>> be separated (I suppose this has to do with DTD support). Probably this
>> means that what I am looking for cannot be done, but I think it is worth
>> asking anyway.
>>
>> Regards,
>>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

Imsieke, Gerrit, le-tex
Hi George,

This is not equivalent. The combined schema that you suggested allows
you to construct documents that are not valid TEI.

For example, it allows this as body content:

     <body>
       <when></when>
       <div absolute="s" type="chapter"></div>
     </body>

which is invalid wrt the TEI schema. The combined schema seems to allow
the union of what any of the two schemas would allow at a given point.

However, the purpose of the extra schema is to further constrain what
the basis schema allows, not to extend it.

I’d like to know whether there is another way to specify these extra
constraints in an adornment schema that may be combined with the
original schema.

Gerrit

On 24.06.2016 11:21, George Bina wrote:

> What about using a schema that combines the two schemas, like
>
> <grammar
>     xmlns="http://relaxng.org/ns/structure/1.0"
>     xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
>     datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
>     <start>
>         <choice>
>          <externalRef
> href="http://www.tei-c.org/Vault/P5/1.7.0/xml/tei/custom/schema/relaxng/tei_all.rng"/>
>
>          <externalRef
> href="https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng"/>
>
>         </choice>
>     </start>
> </grammar>
>
> Note that you need to disable the ID/IDREF checking from
> Options->Preferences -- XML / XML Parser / RELAX NG because there are
> conflicting IDs defined.
>
> Best Regards,
> George
> --
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
>
> On 24/06/16 02:30, Imsieke, Gerrit, le-tex wrote:
>> Hi Gioele,
>>
>> Neither an ODD nor a Schematron approach: You can use a second RNG
>> schema. Here is a sample schema (that also serves as a blog post about
>> this approach):
>> https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng
>>
>> I tried to prescribe div/@type attributes in such a way that the types
>> correspond to DocBook element names, and the grammar is (roughly) the
>> same as in DocBook. So you have parts or chapters in the body, prefaces
>> and dedications in the frontmatter, etc.
>>
>> The nice thing is that you superimpose a bespoke grammar on an
>> off-the-shelf TEI schema. An actual grammar refining an unaltered base
>> schema, if that doesn’t sound compelling. You can’t do this with
>> Schematron so handily.
>>
>> A sample document is here:
>> https://gist.github.com/gimsieke/44748c504783590ef906c7dc0c2e268b
>> If you open it in oXygen and add a type attribute to body/div, you will
>> be presented with a choice of part and chapter.
>> This is the good news.
>> The bad news is that there will be no other completion hints than those
>> from the epischema – unless you swap the xml-model PIs at the top, but
>> then you’ll only have the default TEI vocabulary as suggestions.
>> Maybe we can convince the oXygen people to restrict the autocomplete
>> options to the intersection of the choices that all referenced schemas
>> offer at a given location.
>>
>> Gerrit
>>
>> On 22.06.2016 18:14, Gioele Barabucci wrote:
>>> Hello,
>>>
>>> in ODD, how can I change the constraints of the <div> elements that
>>> appear in a certain position (e.g., /TEI/text/body) while using the
>>> default definition for all the other elements?
>>>
>>> I could specify those constraints as a set of Schematron assertions, but
>>> those would not be picked up by, for example, oXygen for the automatic
>>> completion of element names and attribute values.
>>>
>>> In RelaxNG one can give two different definitions of <div>: one for
>>> those elements appearing in a certain production, and another for all
>>> the others contexts. Can the same thing be done in ODD?
>>>
>>> The use case for this request is that I would like <div>s in
>>> /TEI/text/body to contain only few whitelisted elements, while allowing
>>> <div> in other places (mainly the header) to be unconstrained.
>>>
>>> Note: Element names and element definitions are separate entities in
>>> RelaxNG; in ODD it looks like element names and their definitions cannot
>>> be separated (I suppose this has to do with DTD support). Probably this
>>> means that what I am looking for cannot be done, but I think it is worth
>>> asking anyway.
>>>
>>> Regards,
>>>
>>

--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
[hidden email], http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

James Cummings-4
Hi Gerrit,

I think embedding schematron in your ODD is the right TEI way to
do this (as Lou suggested). It might be a bit fiddly, but that at
least should work (in the sense of validate as you intend).

-James

On 24/06/16 17:31, Imsieke, Gerrit, le-tex wrote:

> Hi George,
>
> This is not equivalent. The combined schema that you suggested
> allows you to construct documents that are not valid TEI.
>
> For example, it allows this as body content:
>
>     <body>
>       <when></when>
>       <div absolute="s" type="chapter"></div>
>     </body>
>
> which is invalid wrt the TEI schema. The combined schema seems
> to allow the union of what any of the two schemas would allow
> at a given point.
>
> However, the purpose of the extra schema is to further
> constrain what the basis schema allows, not to extend it.
>
> I’d like to know whether there is another way to specify these
> extra constraints in an adornment schema that may be combined
> with the original schema.
>
> Gerrit
>
> On 24.06.2016 11:21, George Bina wrote:
>> What about using a schema that combines the two schemas, like
>>
>> <grammar
>>     xmlns="http://relaxng.org/ns/structure/1.0"
>> xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
>> datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
>>     <start>
>>         <choice>
>>          <externalRef
>> href="http://www.tei-c.org/Vault/P5/1.7.0/xml/tei/custom/schema/relaxng/tei_all.rng"/>
>>
>>
>>          <externalRef
>> href="https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng"/>
>>
>>
>>         </choice>
>>     </start>
>> </grammar>
>>
>> Note that you need to disable the ID/IDREF checking from
>> Options->Preferences -- XML / XML Parser / RELAX NG because
>> there are
>> conflicting IDs defined.
>>
>> Best Regards,
>> George
>> --
>> George Cristian Bina
>> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
>> http://www.oxygenxml.com
>>
>> On 24/06/16 02:30, Imsieke, Gerrit, le-tex wrote:
>>> Hi Gioele,
>>>
>>> Neither an ODD nor a Schematron approach: You can use a
>>> second RNG
>>> schema. Here is a sample schema (that also serves as a blog
>>> post about
>>> this approach):
>>> https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng 
>>>
>>>
>>> I tried to prescribe div/@type attributes in such a way that
>>> the types
>>> correspond to DocBook element names, and the grammar is
>>> (roughly) the
>>> same as in DocBook. So you have parts or chapters in the
>>> body, prefaces
>>> and dedications in the frontmatter, etc.
>>>
>>> The nice thing is that you superimpose a bespoke grammar on an
>>> off-the-shelf TEI schema. An actual grammar refining an
>>> unaltered base
>>> schema, if that doesn’t sound compelling. You can’t do this with
>>> Schematron so handily.
>>>
>>> A sample document is here:
>>> https://gist.github.com/gimsieke/44748c504783590ef906c7dc0c2e268b 
>>>
>>> If you open it in oXygen and add a type attribute to
>>> body/div, you will
>>> be presented with a choice of part and chapter.
>>> This is the good news.
>>> The bad news is that there will be no other completion hints
>>> than those
>>> from the epischema – unless you swap the xml-model PIs at the
>>> top, but
>>> then you’ll only have the default TEI vocabulary as suggestions.
>>> Maybe we can convince the oXygen people to restrict the
>>> autocomplete
>>> options to the intersection of the choices that all
>>> referenced schemas
>>> offer at a given location.
>>>
>>> Gerrit
>>>
>>> On 22.06.2016 18:14, Gioele Barabucci wrote:
>>>> Hello,
>>>>
>>>> in ODD, how can I change the constraints of the <div>
>>>> elements that
>>>> appear in a certain position (e.g., /TEI/text/body) while
>>>> using the
>>>> default definition for all the other elements?
>>>>
>>>> I could specify those constraints as a set of Schematron
>>>> assertions, but
>>>> those would not be picked up by, for example, oXygen for the
>>>> automatic
>>>> completion of element names and attribute values.
>>>>
>>>> In RelaxNG one can give two different definitions of <div>:
>>>> one for
>>>> those elements appearing in a certain production, and
>>>> another for all
>>>> the others contexts. Can the same thing be done in ODD?
>>>>
>>>> The use case for this request is that I would like <div>s in
>>>> /TEI/text/body to contain only few whitelisted elements,
>>>> while allowing
>>>> <div> in other places (mainly the header) to be unconstrained.
>>>>
>>>> Note: Element names and element definitions are separate
>>>> entities in
>>>> RelaxNG; in ODD it looks like element names and their
>>>> definitions cannot
>>>> be separated (I suppose this has to do with DTD support).
>>>> Probably this
>>>> means that what I am looking for cannot be done, but I think
>>>> it is worth
>>>> asking anyway.
>>>>
>>>> Regards,
>>>>
>>>
>


--
Dr James Cummings, Academic IT Services, University of Oxford,
TEI Consultations: [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

Gioele Barabucci-2
In reply to this post by Imsieke, Gerrit, le-tex
Am 24.06.2016 um 01:30 schrieb Imsieke, Gerrit, le-tex:
> Hi Gioele,
>
> Neither an ODD nor a Schematron approach: You can use a second RNG
> schema. Here is a sample schema (that also serves as a blog post about
> this approach):
> https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng

Hello Gerrit,

using <anyName>+<except> in <start> is a nice trick!

My only problem now is that using your technique as it is raises a lot
the bar to make adjustments to the guidelines I am currently working on.
Collaborators would then need to learn also RelaxNG (and a non
widespread trick) in addition to ODD.

I would suggest the ODD maintainers to seriously consider integrating
this technique to allow context-dependent refinements without using
Schematron (see my other reply to Lou Bernhard's email).

Regards,

--
Gioele Barabucci <[hidden email]>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

Gioele Barabucci-2
In reply to this post by Lou Burnard-6
Am 22.06.2016 um 23:06 schrieb Lou Burnard:
> The TEI Simple ODD includes a set of Schematron rules designed to
> prevent child elements which are permitted in the Header from appearing
> in the <body>. They appear as <constraintSpec>s, like other Schematron
> rules, and are processed as such by the current stylesheets, so that
> oXygen will certainly flag any such elements as errors: I am not sure
> what you mean by "automatic completion of element names" in this context.

Hello Lou,

the problem with Schematron is that it can only constrain; Schematron
rules provide no support for inference.

A practical example: if I want to say that certain `<div>` elements con
contain only `<l>` elements, I could write a Schematron rule like

     <assert test="not(div[@type='page'][not(./l)])"/>

but oXygen would never be able to infer from that, that when the users
go to add a new element inside a `<div type='page'>` they should only
see `l` as a possibility, and none of the other elements that can appear
in generic `<div>` elements.

Regards,

--
Gioele Barabucci <[hidden email]>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

George Bina
Hi,

Maybe Schematron Quick Fix will be helpful in this context? This should
allow you to offer a fix that will replace all children elements of the
page div with "l" - see the SQF session at XML Prague 2016:
https://www.youtube.com/watch?v=RLMc0B0di5s&list=PLQpqh98e9RgWWlRDQv4W6T8-jPST4v4YZ&index=6

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

On 24/06/16 20:28, Gioele Barabucci wrote:

> Am 22.06.2016 um 23:06 schrieb Lou Burnard:
>> The TEI Simple ODD includes a set of Schematron rules designed to
>> prevent child elements which are permitted in the Header from appearing
>> in the <body>. They appear as <constraintSpec>s, like other Schematron
>> rules, and are processed as such by the current stylesheets, so that
>> oXygen will certainly flag any such elements as errors: I am not sure
>> what you mean by "automatic completion of element names" in this context.
>
> Hello Lou,
>
> the problem with Schematron is that it can only constrain; Schematron
> rules provide no support for inference.
>
> A practical example: if I want to say that certain `<div>` elements con
> contain only `<l>` elements, I could write a Schematron rule like
>
>      <assert test="not(div[@type='page'][not(./l)])"/>
>
> but oXygen would never be able to infer from that, that when the users
> go to add a new element inside a `<div type='page'>` they should only
> see `l` as a possibility, and none of the other elements that can appear
> in generic `<div>` elements.
>
> Regards,
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

George Bina
In reply to this post by Imsieke, Gerrit, le-tex
Hi Gerrit,

If you specify 3 xml-model PIs at the start, first the one that combines
the two schemas

<?xml-model href="test.rng" type="application/xml"
schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model
href="http://www.tei-c.org/Vault/P5/1.7.0/xml/tei/custom/schema/relaxng/tei_all.rng"
type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model
href="https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng"
type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>

then you will get

- oXygen content completion using the first schema, which is the reunion
of the two initial schemas, thus you will get the as proposlas values
for the type attribute and the TEI structural elements
- validation with both both schemas (from the last 2 xml-model PIs)

So, the content completion will be a little bit more relaxed but
anything invalid will be notified by the additional validation from the
last 2 xml-model PIs.

Using an XML catalog and local copies of the schemas is strongly
recommended :).

Maybe we can take advantage of parentRef and redefining patterns to be
able to achieve what you want... For example imagine that the TEI schema
will be built using two files:

main schema that defines a pattern div.type.TYPE as text and brings in
the TEI schema using externalRef

TEI schema that for the div type attribute says parentRef to div.type.TYPE

Then, if you want a constrained TEI schema, you defined your TEI schema
that includes the TEI schema and inside the include element redefines
the div.type.TYPE pattern to be a choice between the values you want.

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

On 24/06/16 19:31, Imsieke, Gerrit, le-tex wrote:

> Hi George,
>
> This is not equivalent. The combined schema that you suggested allows
> you to construct documents that are not valid TEI.
>
> For example, it allows this as body content:
>
>      <body>
>        <when></when>
>        <div absolute="s" type="chapter"></div>
>      </body>
>
> which is invalid wrt the TEI schema. The combined schema seems to allow
> the union of what any of the two schemas would allow at a given point.
>
> However, the purpose of the extra schema is to further constrain what
> the basis schema allows, not to extend it.
>
> I’d like to know whether there is another way to specify these extra
> constraints in an adornment schema that may be combined with the
> original schema.
>
> Gerrit
>
> On 24.06.2016 11:21, George Bina wrote:
>> What about using a schema that combines the two schemas, like
>>
>> <grammar
>>     xmlns="http://relaxng.org/ns/structure/1.0"
>>     xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
>>     datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
>>     <start>
>>         <choice>
>>          <externalRef
>> href="http://www.tei-c.org/Vault/P5/1.7.0/xml/tei/custom/schema/relaxng/tei_all.rng"/>
>>
>>
>>          <externalRef
>> href="https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng"/>
>>
>>
>>         </choice>
>>     </start>
>> </grammar>
>>
>> Note that you need to disable the ID/IDREF checking from
>> Options->Preferences -- XML / XML Parser / RELAX NG because there are
>> conflicting IDs defined.
>>
>> Best Regards,
>> George
>> --
>> George Cristian Bina
>> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
>> http://www.oxygenxml.com
>>
>> On 24/06/16 02:30, Imsieke, Gerrit, le-tex wrote:
>>> Hi Gioele,
>>>
>>> Neither an ODD nor a Schematron approach: You can use a second RNG
>>> schema. Here is a sample schema (that also serves as a blog post about
>>> this approach):
>>> https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng
>>>
>>>
>>> I tried to prescribe div/@type attributes in such a way that the types
>>> correspond to DocBook element names, and the grammar is (roughly) the
>>> same as in DocBook. So you have parts or chapters in the body, prefaces
>>> and dedications in the frontmatter, etc.
>>>
>>> The nice thing is that you superimpose a bespoke grammar on an
>>> off-the-shelf TEI schema. An actual grammar refining an unaltered base
>>> schema, if that doesn’t sound compelling. You can’t do this with
>>> Schematron so handily.
>>>
>>> A sample document is here:
>>> https://gist.github.com/gimsieke/44748c504783590ef906c7dc0c2e268b
>>> If you open it in oXygen and add a type attribute to body/div, you will
>>> be presented with a choice of part and chapter.
>>> This is the good news.
>>> The bad news is that there will be no other completion hints than those
>>> from the epischema – unless you swap the xml-model PIs at the top, but
>>> then you’ll only have the default TEI vocabulary as suggestions.
>>> Maybe we can convince the oXygen people to restrict the autocomplete
>>> options to the intersection of the choices that all referenced schemas
>>> offer at a given location.
>>>
>>> Gerrit
>>>
>>> On 22.06.2016 18:14, Gioele Barabucci wrote:
>>>> Hello,
>>>>
>>>> in ODD, how can I change the constraints of the <div> elements that
>>>> appear in a certain position (e.g., /TEI/text/body) while using the
>>>> default definition for all the other elements?
>>>>
>>>> I could specify those constraints as a set of Schematron assertions,
>>>> but
>>>> those would not be picked up by, for example, oXygen for the automatic
>>>> completion of element names and attribute values.
>>>>
>>>> In RelaxNG one can give two different definitions of <div>: one for
>>>> those elements appearing in a certain production, and another for all
>>>> the others contexts. Can the same thing be done in ODD?
>>>>
>>>> The use case for this request is that I would like <div>s in
>>>> /TEI/text/body to contain only few whitelisted elements, while allowing
>>>> <div> in other places (mainly the header) to be unconstrained.
>>>>
>>>> Note: Element names and element definitions are separate entities in
>>>> RelaxNG; in ODD it looks like element names and their definitions
>>>> cannot
>>>> be separated (I suppose this has to do with DTD support). Probably this
>>>> means that what I am looking for cannot be done, but I think it is
>>>> worth
>>>> asking anyway.
>>>>
>>>> Regards,
>>>>
>>>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [ODD] Changing only <div>s in certain contexts

Imsieke, Gerrit, le-tex
In reply to this post by Imsieke, Gerrit, le-tex
Hi George and Gioele,

After half a year, I found some time to continue working on this approach.

To recap, the approach is to use the schema of an unaltered default
customization, for example tei_allPlus.rng, together with another RNG
schema that will allow almost anything everywhere, except for certain
elements such as div and floatingText. This second schema provides a
grammar that specifies in which order and cardinality these typed
elements may appear and how they may be nested.

The remaining problem that we discussed was about how oXygen’s
context-aware editing aids can make use of the combined rules. When
associating these schemas with two xml-model instructions, only the
schema of the first xml-model will be used for element name suggestions.
So you can choose to have the plain TEI rules with no type restriction,
or a very sparse list that suggests that you can only insert divs and a
few other elements.

Combining both schemas in NVDL
(http://www.le-tex.de/resource/schema/tei-cssa/tei_allPlus_docbook-like-divs.nvdl)
improves the situation. The elements that oXygen now offers seem to be
the union of the elements that each schema allows in a given context.

Since the second schema needs to explicitly model each element that is
allowed to contain typed divs and floatingTexts, the 'anything' define
of the second schema contains references to some concrete elements,
namely div, floatingText, front, body, and back. These few elements now
also, and often falsely, appear in oXygen’s list of permitted elements.
When the user enters these, they will immediately be flagged as
validation errors though.

This is a slight drawback of the NVDL approach. The approach comes,
however, with a nice benefit, and that is the context- and grammar-aware
lists of permitted type attribute values for div and floatingText. So I
assert that it’s useful and arguably more adequate than shoehorning
grammatical rules into Schematron.

You can open this URL in oXygen to see a sample document and play around
with its div & floatingText nesting rules:
https://subversion.le-tex.de/common/schema/tei-cssa/sample/tei-epischema_sample.xml

Gerrit


On 24.06.2016 18:31, Imsieke, Gerrit, le-tex wrote:

> Hi George,
>
> This is not equivalent. The combined schema that you suggested allows
> you to construct documents that are not valid TEI.
>
> For example, it allows this as body content:
>
>     <body>
>       <when></when>
>       <div absolute="s" type="chapter"></div>
>     </body>
>
> which is invalid wrt the TEI schema. The combined schema seems to allow
> the union of what any of the two schemas would allow at a given point.
>
> However, the purpose of the extra schema is to further constrain what
> the basis schema allows, not to extend it.
>
> I’d like to know whether there is another way to specify these extra
> constraints in an adornment schema that may be combined with the
> original schema.
>
> Gerrit
>
> On 24.06.2016 11:21, George Bina wrote:
>> What about using a schema that combines the two schemas, like
>>
>> <grammar
>>     xmlns="http://relaxng.org/ns/structure/1.0"
>>     xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
>>     datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
>>     <start>
>>         <choice>
>>          <externalRef
>> href="http://www.tei-c.org/Vault/P5/1.7.0/xml/tei/custom/schema/relaxng/tei_all.rng"/>
>>
>>
>>          <externalRef
>> href="https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng"/>
>>
>>
>>         </choice>
>>     </start>
>> </grammar>
>>
>> Note that you need to disable the ID/IDREF checking from
>> Options->Preferences -- XML / XML Parser / RELAX NG because there are
>> conflicting IDs defined.
>>
>> Best Regards,
>> George
>> --
>> George Cristian Bina
>> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
>> http://www.oxygenxml.com
>>
>> On 24/06/16 02:30, Imsieke, Gerrit, le-tex wrote:
>>> Hi Gioele,
>>>
>>> Neither an ODD nor a Schematron approach: You can use a second RNG
>>> schema. Here is a sample schema (that also serves as a blog post about
>>> this approach):
>>> https://subversion.le-tex.de/common/schema/tei-cssa/docbook-like-divs.rng
>>>
>>>
>>> I tried to prescribe div/@type attributes in such a way that the types
>>> correspond to DocBook element names, and the grammar is (roughly) the
>>> same as in DocBook. So you have parts or chapters in the body, prefaces
>>> and dedications in the frontmatter, etc.
>>>
>>> The nice thing is that you superimpose a bespoke grammar on an
>>> off-the-shelf TEI schema. An actual grammar refining an unaltered base
>>> schema, if that doesn’t sound compelling. You can’t do this with
>>> Schematron so handily.
>>>
>>> A sample document is here:
>>> https://gist.github.com/gimsieke/44748c504783590ef906c7dc0c2e268b
>>> If you open it in oXygen and add a type attribute to body/div, you will
>>> be presented with a choice of part and chapter.
>>> This is the good news.
>>> The bad news is that there will be no other completion hints than those
>>> from the epischema – unless you swap the xml-model PIs at the top, but
>>> then you’ll only have the default TEI vocabulary as suggestions.
>>> Maybe we can convince the oXygen people to restrict the autocomplete
>>> options to the intersection of the choices that all referenced schemas
>>> offer at a given location.
>>>
>>> Gerrit
>>>
>>> On 22.06.2016 18:14, Gioele Barabucci wrote:
>>>> Hello,
>>>>
>>>> in ODD, how can I change the constraints of the <div> elements that
>>>> appear in a certain position (e.g., /TEI/text/body) while using the
>>>> default definition for all the other elements?
>>>>
>>>> I could specify those constraints as a set of Schematron assertions,
>>>> but
>>>> those would not be picked up by, for example, oXygen for the automatic
>>>> completion of element names and attribute values.
>>>>
>>>> In RelaxNG one can give two different definitions of <div>: one for
>>>> those elements appearing in a certain production, and another for all
>>>> the others contexts. Can the same thing be done in ODD?
>>>>
>>>> The use case for this request is that I would like <div>s in
>>>> /TEI/text/body to contain only few whitelisted elements, while allowing
>>>> <div> in other places (mainly the header) to be unconstrained.
>>>>
>>>> Note: Element names and element definitions are separate entities in
>>>> RelaxNG; in ODD it looks like element names and their definitions
>>>> cannot
>>>> be separated (I suppose this has to do with DTD support). Probably this
>>>> means that what I am looking for cannot be done, but I think it is
>>>> worth
>>>> asking anyway.
>>>>
>>>> Regards,
>>>>
>>>
>

--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
[hidden email], http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
Loading...