[dsdl-comment] Re: Section with a child section (which is attachedto its parent), and the child section itself has a child section (which isnot attached to its parent)

From: George Cristian Bina <george@oxygenxml.com>
Date: Wed May 21 2008 - 23:26:00 UTC

Hi Roger,

Yes, the attach action performs that, it attaches the current work
section to the parent diary section. But each action forks the
processing and the child sections will be processed both for validate
and for the allow actions. The solution to specify useMode="distance"
for the attach means that the distance section will be validated twice
against the Distance.xsd schema. A better approach will probably be to
use a mode that just allows anything like in the sample below [1].

What you need to remember is that the actions are applied on the current
section and for each action the processing forks and child sections are
also processed, for each action.

The actions mainly split into actions that perform validation: validate,
allow, reject and actions that form the validation candidates, the
document fragments on which the validate actions act: attach, unwrap and
attachPlaceholder. The NVDL script determines the actions to be executed
on each section. Assuming for instance a simplified case when each
section has only one child section (except the last one which has no
child section) and that each NVDL rule has only one action then the NVDL
script will determine one vector containing pairs formed by a section
and its associated action:

(Section1, Action1), (Section2, Action2),... (SectionN, ActionN)

We can have for example:

(S1, Validate with X.xsd), (S2, attach), (S3, validate with Y.xsd) (S4,
attach)

In this case X.xsd will validate a document fragment obtained from S1
and S2 and Y.xsd will validate a document fragment obtained from S3 and S4.

The point is that the attach action attaches the section it applied on
to the validation candidate for the nearest preceding validate action.
The attach on S4 does not attach S4 to the first validate action, it
attaches it to the second validate actions as that is closer. The
validation actions (validate, attach, reject) break the processing of a
parent validate action and further attach and unwrap actions will apply
to that validate action.

(S1, validate), (S2, unwrap), (S3, attach)

will apply the validate action on a fragment containing S1 and S3 while
S2 will be ignored. To quickly understand unwrap just read it "ignore".

Now, remove the restriction of one action per rule and instead of one
mapping vector (called interpretation in the spec) you will end up with
a set of such interpretations. Here it is important to know a rule that
says that the biggest validation candidate deprecates the ones that are
subsets of it. For instance if we have:

(S1, validate1) (S2, validate2) (S3, validate3)
(S1, validate1) (S2, attach) (S3, validate3)
(S1, validate1) (S2, validate2) (S3, attach)
(S1, validate1) (S2, attach) (S3, attach)

then the validate1 will be applied on a fragment containing S1, S2 and
S3 and the validate2 action will be applied on a fragment containing S2
and S3 as these are the largest validation candidates.

Remove now the limitation to have maximum one child section and the
interpretation will be a tree instead of a vector but the same rules
apply for processing.

[1] sample NVDL script

<?xml version="1.0"?>
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
startMode="diary">

     <mode name="diary">
         <namespace ns="http://www.diary.org">
             <validate schema="Diary.xsd" useMode="activity"/>
         </namespace>
     </mode>

     <mode name="activity">
         <namespace ns="http://www.work.org">
             <validate schema="Work.rng" useMode="distance"/>
             <attach useMode="allow"/>
         </namespace>
     </mode>

     <mode name="allow">
         <anyNamespace>
             <allow/>
         </anyNamespace>
     </mode>

     <mode name="distance">
         <namespace ns="http://www.distance.org">
             <validate schema="Distance.xsd"/>
         </namespace>
     </mode>
</rules>

Best Regards,
George

-- 
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Costello, Roger L. wrote:
> Thanks George!
> 
> I guess that I don't understand the <attach /> element.
> 
> I thought that the following mode means, "Validate the
> http://www.work.org section against Work.rng, then attach the section
> to its parent section and validate the combination of the parent plus
> child sections against the schema specified by the parent section
> (Diary.xsd). Is this an incorrect understanding?
> 
>      <mode name="activity">
>          <namespace ns="http://www.work.org">
>              <validate schema="Work.rng"
>                  useMode="distance"/>
>              <attach/>
>          </namespace>
>      </mode>
> 
> 
> What does it mean to have a useMode on attach?  That is, what does this
> mean:
> 
>    <attach useMode="distance"/>
> 
> Thanks again George.  I appreciate all your help.  
> 
> /Roger
> --
> DSDL comments
> 
> To unsubscribe, please send a message with the
> command  "unsubscribe" to dsdl-comment-request@dsdl.org
> (mailto:dsdl-comment-request@dsdl.org?Subject=subscribe)
> 
--
DSDL comments
To unsubscribe, please send a message with the
command  "unsubscribe" to dsdl-comment-request@dsdl.org
(mailto:dsdl-comment-request@dsdl.org?Subject=unsubscribe)
Received on Thu May 22 01:26:04 2008

This archive was generated by hypermail 2.1.8 : Thu May 22 2008 - 13:53:05 UTC