Hi David,
Here it is an example to show the abstract usage of parentRef. I
understand abstract as in a programming language when you define an
abstract method that requires implementation.
Let's suppose we want to define a list of contacts. A contact will
contain a name and an address. We will make the address abstract using a
parentRef, that is we do not provide a definition for action and the
schema cannot be used directly (exactly as in the case of an abstract
class, you cannot use that directly, you need to use a derived class
that implements the abstract method and the abstract method does not
provide an implementation).
module.rnc
==========
start = contactDetails
contactDetails =
element contact {
element name {
element first { text },
element last { text }
},
parent address
}
Then we will define two implementation of the address pattern as follows:
contactUK.rnc
=============
start = external "module.rnc"
address =
element street { text },
element postcode { text }
and
contactUK.rnc
=============
start = external "module.rnc"
address =
element street { text },
element zipcode { text }
Now, the contacts is defined as a list of UK or US contacts:
contacts.rnc
============
start =
element contacts {
(external "contactUS.rnc" | external "contactUK.rnc")+
}
The contacts.rnc will validate a document like:
<contacts>
<contact>
<name>
<first>us</first>
<last>us</last>
</name>
<street>us</street>
<zipcode>us</zipcode>
</contact>
<contact>
<name>
<first>uk</first>
<last>uk</last>
</name>
<street>uk</street>
<postcode>uk</postcode>
</contact>
</contacts>
As you can see the address pattern behave like an abstract method, it is
"implemented" in the contactUK and contactUS and the parent reference is
resolved to two different named patterns depending on the context from
where the module.rnc is referred from.
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Dave Pawson wrote:
> re parentRef
>
>
>> I would not emphasize the term re-use as that may imply that this is the
>> only use case for parentRef. Imagine that you have the grammar that uses
>> parentRef and this grammar is placed in a file and that it is referred
>> using externalRef from two different parent grammars. Each of these two
>> parent grammars must define the referred pattern but they can define it
>> differently. So the parentRef in this case acts like calling an abstract
>> pattern that is implemented/defined in the parent grammar.
>
> I don't see it as abstract? The pattern is 'real', in use as if defined
> in the referencing schema?
>
> For the grammar to be used, i.e. useful, I can refer to either parent A or B,
> both of which must define the pattern. When I validate an instance
> I will use schema A or B, I can't use the referencing schema, since
> it does not exist as an entity itself?
>
> Agreed 'use' is better than 're-use' though.
> --
> Dave Pawson
> XSLT XSL-FO FAQ.
> http://www.dpawson.co.uk
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/2U_rlB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/rng-users/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/