You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2010/06/21 04:55:26 UTC
[jira] Assigned: (XERCESJ-846) key/keyref: referred key is not
found when node and its child are selected
[ https://issues.apache.org/jira/browse/XERCESJ-846?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Glavassevich reassigned XERCESJ-846:
--------------------------------------------
Assignee: Michael Glavassevich (was: Kohsuke Kawaguchi)
> key/keyref: referred key is not found when node and its child are selected
> --------------------------------------------------------------------------
>
> Key: XERCESJ-846
> URL: https://issues.apache.org/jira/browse/XERCESJ-846
> Project: Xerces2-J
> Issue Type: Bug
> Components: XML Schema 1.0 Structures
> Affects Versions: 2.6.0
> Environment: Operating System: Solaris
> Platform: Sun
> Reporter: Kohsuke Kawaguchi
> Assignee: Michael Glavassevich
> Attachments: bug25171.zip, bug25171.zip
>
>
> A parser reports that a referred key is not found in the context of an element
> in case
> when a keyref constraint refers to a key constraint with a selector that is a
> union xpath
> expression selecting a node and its child (see test.java, test.xsd, test.xml
> below).
> The bug appears in jdk1.5.0beta-b22 and affects a new JCK1.5 test:
>
> api/xml_schema/suntest/identity/idc006/idc006.nogen.html#idc006.nogen.v00
> ------------------------------------test.java-----------------------------
> import javax.xml.parsers.SAXParserFactory;
> import javax.xml.parsers.SAXParser;
> import org.xml.sax.SAXException;
> import org.xml.sax.SAXParseException;
> import org.xml.sax.helpers.DefaultHandler;
> public class test {
> protected static class ErrorHandler extends DefaultHandler {
> public void error(SAXParseException e) throws SAXException {
> System.out.println(e.toString());
> }
> public void fatalError(SAXParseException e) throws SAXException {
> System.out.println(e.toString());
> }
> }
> public static void main(String [] args) {
> test t = new test();
>
> System.out.println("Parsing valid test.xml...");
> t.parse("test.xml");
> }
>
> private void parse(String xmlFile) {
> ErrorHandler eh = new ErrorHandler();
> try {
> SAXParserFactory spf = SAXParserFactory.newInstance();
> spf.setNamespaceAware(true);
> spf.setValidating(true);
> SAXParser parser = spf.newSAXParser();
> parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLa
> nguage",
> "http://www.w3.org/2001/XMLSchema");
> parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSo
> urce",
> "test.xsd");
>
> parser.parse(xmlFile, (DefaultHandler)eh);
> } catch (Exception e) {
> System.out.println(e.toString());
> }
> }
> }
> ------------------------------------test.xsd------------------------------
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:tn="foo"
> targetNamespace="foo" elementFormDefault="qualified">
> <xs:element name="root">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="a">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="tn:b"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="ref" maxOccurs="unbounded" minOccurs="0"
> type="xs:string" />
> </xs:sequence>
> </xs:complexType>
>
> <!-- identity constraint -->
> <xs:key name="key">
> <xs:selector xpath=".//tn:a/tn:b|.//tn:a/tn:b/tn:c"/>
> <xs:field xpath="@id"/>
> </xs:key>
> <xs:keyref name="keyref" refer="tn:key">
> <xs:selector xpath=".//tn:ref"/>
> <xs:field xpath="."/>
> </xs:keyref>
> </xs:element>
>
> <xs:element name="c">
> <xs:complexType>
> <xs:attribute name="id" type="xs:string"/>
> </xs:complexType>
> </xs:element>
>
> <xs:element name="b">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="tn:c" minOccurs="0" />
> </xs:sequence>
> <xs:attribute name="id" type="xs:string"/>
> </xs:complexType>
> </xs:element>
> </xs:schema>
> ------------------------------------test.xml------------------------------
> <?xml version="1.0" encoding="utf-8"?>
> <root xmlns="foo">
> <a>
> <b id="id1">
> <c id="id2"/>
> </b>
> </a>
> <ref>id2</ref>
> </root>
> --------------------------------------------------------------------------
> % java -showversion test
> java version "1.5.0-beta"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b22)
> Java HotSpot(TM) Client VM (build 1.5.0-beta-b22, mixed mode)
> Parsing valid test.xml...
> org.xml.sax.SAXParseException: Key 'keyref' with value 'ID Value: id2' not
> found for
> identity constraint of element 'root'.
> -------------------------------------------------------------------------
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org