emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Org schemas we talked to be non-free, was: [ELPA] New package: repol


From: Eli Zaretskii
Subject: Re: Org schemas we talked to be non-free, was: [ELPA] New package: repology.el
Date: Tue, 26 Jan 2021 17:57:37 +0200

> From: Richard Stallman <rms@gnu.org>
> Cc: ulm@gentoo.org, bugs@gnu.support, ulm@gentoo.org,
>       emacs-devel@gnu.org, ams@gnu.org, arthur.miller@live.com,
>       dgutov@yandex.ru
> Date: Tue, 26 Jan 2021 01:01:07 -0500
> 
>   > A schema can be similarly "generalized" (a.k.a. "extended") without
>   > changing it: you include the schema in your own and then add your own
>   > data types and conditions.
> 
> Can you please show me how sort of generalization is done?  It isn't
> allowed by editing the schema; the license of the schema does not give
> permission for such modifications.
>   
> Is there some other mechanism that can be used to do that job?  If so,
> could you please show me something about that mechanism, and what it
> can and can't do?

Basically you reference the original schema in yours, and then add
your extensions or overrides.

There are several methods available for that, but the simplest one is
to define new elements using the ones defined in the original schema.
Here's a simple example:

  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
  <xs:element name="USaddress">
   <xs:complexType>
    <xs:sequence>
     <xs:element name="street1" type="xs:string" minOccurs="0"/>
     <xs:element name="street2" type="xs:string" minOccurs="0"/>
     <xs:element name="city"    type="xs:string"/>
     <xs:element name="state"   type="xs:string"/>
     <xs:element name="zip"     type="xs:string" minOccurs="0"/>
    </xs:sequence>
   </xs:complexType>
  </xs:element>
  </xs:schema>

This defines an element "US Address" using xs:string type defined in
the W3C XMLSchema.  Then you can define a new element "Contact", on
top of that, by adding a name to an address:

  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
   <!-- Reference to External Module containing USaddress definition -->
   <xs:include schemaLocation="USaddress.xsd"/>
   <!-- Element containing USaddress element from included module -->
   <xs:complexType name="contact">
    <xs:sequence>
     <xs:element name="Name" type="xs:string"/>
     <xs:element ref="USaddress"/>
    </xs:sequence>
   </xs:complexType>
  </xs:schema>

You can also extend an existing type:

  <xs:complexType name="extendedNameType">
    <xs:extension base="nameType">
      <xs:sequence>
        <xs:element name="gen" type="xs:string"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexType>

This extends the existing type "nameType" (presumably defined in some
schema you include as above) by adding to it the sub-element "gen".

There's also a facility to redefine existing data types.

Etc. etc.  This way, there's no reason to change the original schema,
you just extend it in your own schema, using the original one as the
baseline.

A few resources to read up on this:

  https://www.w3schools.com/xml/el_extension.asp
  https://www.ibm.com/developerworks/library/x-xtendschema/index.html
  
https://stackoverflow.com/questions/3392402/how-do-i-extend-a-base-schema-with-custom-elements-while-remaining-open-to-chang



reply via email to

[Prev in Thread] Current Thread [Next in Thread]