Re: Using <unique> for multilingual elements

Hi,

Identity-constraints were enabled in Libxml2 version 2.6.18, so I guess
you use a previous version. With Libxml2 2.6.19 I get the following:

kbu@librax:/data/home/kbuchcik/gnomecvs/tests$ xmllint --noout --schema
changelog093.xsd changelog093.xml
changelog093.xml:7: element description: Schemas validity error :
Element '{http://www.blackperl.com/XML/ChangeLog}description' [unique
'changelogDescriptionLangConstraint']: Duplicate key-sequence found.
changelog093.xml fails to validate

With this instance:

<changelog
	xmlns="http://www.blackperl.com/XML/ChangeLog" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.blackperl.com/XML/ChangeLog
changelog093.xsd">
	<description lang="PL"/>
	<description lang="PL"/>
	<release version="1" date="2005-04-08T21:12:00">
		<item>
			<file path="abc"/>
			<description lang="FR"/>
		</item>
	</release>
</changelog>

Unfortunately this case revealed a memory leak :-( It's fixed in CVS,
xmlschemas.c (rev. 1.129).

Can we use your schema for regression tests?

See www.xmlsoft.org if you have further questions.

Regards,

Kasimier

On Fri, 2005-04-08 at 10:35 -0700, Randy J. Ray wrote:
> I'm working on a schema spec for some open-source work of mine. In it,
> I want to define an element called <documentation>, for obvious uses.
> I would also like to limit it to one instance per scope (it will be
> used at several context levels). Here's the catch: I want to allow
> multiple occurrances if an attribute "lang" is different. So, only one
> *English* version, and perhaps a Russian one, or a Greek one, etc.
> 
> This is the block that defines the complexType:
> 
>   <xsd:complexType id="descriptionType" name="descriptionType">
>     <xsd:annotation>
>       <xsd:documentation>
>         A description block is used to document everything from specific change
>         items to the release as a whole.
>       </xsd:documentation>
>     </xsd:annotation>
>     <xsd:simpleContent>
>       <xsd:extension base="xsd:string">
>         <xsd:attribute default="en-US" name="lang" type="xsd:language" />
>       </xsd:extension>
>     </xsd:simpleContent>
>   </xsd:complexType>
> 
> Here's an example of an element declaration that references a type
> that references the above. This declaration includes a unique
> constraint:
> 
>   <xsd:element id="item" name="item" nillable="false" type="tns:itemType">
>     <xsd:annotation>
>       <xsd:documentation>
>         An item element contains a single block representing an itemType.
>       </xsd:documentation>
>     </xsd:annotation>
>     <xsd:unique name="itemDescriptionLangConstraint">
>       <xsd:selector xpath="tns:description" />
>       <xsd:field xpath="@lang" />
>     </xsd:unique>
>   </xsd:element>
> 
> This *looks* like it should be correct. However, the xsltproc
> command-line tool from libxslt doesn't implement <unique>, yet. I get
> warnings of an unimplemented feature  exactly as many times as I have
> that tag. I haven't been able to get a working Java-based tool for
> plain validation,. so I haven't been able to test it.
> 
> Any advice? Am I on the right track?
> 
> The full schema, if you want to look at it all in context, can be viewed here:
> 
>     http://www.blackperl.com/XML/ChangeLog/changelog093.xsd
> 
> Randy

Received on Friday, 8 April 2005 20:17:15 UTC