Hi Guy,

The default namespace does not apply to XPath expressions, so you must use 
prefixes for names which have a namespace. The following should work:

<xs:element xmlns:a="http://www.fks.be/fsm"; ...>
...
<xs:key name="state-name-pk">
 <xs:selector xpath="./a:state"/>
 <xs:field xpath="@name"/>
</xs:key>
<xs:keyref name="sn1" refer="state-name-pk">
 <xs:selector xpath="./a:transition"/>
 <xs:field xpath="@from"/>
</xs:keyref>
<xs:keyref name="sn2" refer="state-name-pk">
 <xs:selector xpath="./a:transition"/>
 <xs:field xpath="@to"/>
</xs:keyref>
<xs:keyref name="sn3" refer="state-name-pk">
 <xs:selector xpath="."/>
 <xs:field xpath="@start"/>
</xs:keyref>
</xs:element>

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

Guy Thomas <[EMAIL PROTECTED]> wrote on 05/18/2006 01:38:19 AM:

> Can anybody tell me why I get the error message shown in the Subject 
> when running the sample Count program as follows?
> 
> I am trying to validate an xml instance against a schema.
> 
> java -classpath xercesSamples.jar:xercesImpl.jar:xml-apis.jar 
> dom.Counter -v -s fsm.xml
> 
> The xml and xsd files are listed below.
> 
> Thank you
> 
> PS. I also tried specifying 1.1 in the xml processing instruction, both 
> in the xml and xsd, but then I get:
> 
> "XML version "1.1" is not supported, only XML 1.0 is supported."
> 
> -------------------
> 
> This is fsm.xml:
> 
> <?xml version="1.0" ?>
> <fsm trim="true"
>       xmlns="http://www.fks.be/fsm";
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>       xsi:schemaLocation="http://www.fks.be/fsm fsm.xsd">
> 
>    <process name="example.1"
>             start="state1">
> 
>      <state name="state1"
>             terminal="false">
>        <description>
>          This is state #1.
>        </description>
>        <do-activity>
>          example.1.state.1.activity
>        </do-activity>
>      </state>
> 
>      <state name="2"
>             terminal="true">
>        <description>
>          This is state #2.
>        </description>
>        <do-activity>
>          example.1.state.2.activity
>        </do-activity>
>      </state>
> 
>      <transition from="state1"
>                    to="2">
>        <description>
>          Go from #1 to #2
>        </description>
>        <guard>
>          example.1.transition.1-2
>          <fail/>
>        </guard>
>      </transition>
> 
>    </process>
> 
>    <spawn-process name="example.1"/>
> 
> </fsm>
> 
> -------------------
> 
> This is fsm.xsd:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>             targetNamespace="http://www.fks.be/fsm";
>             xmlns="http://www.fks.be/fsm";
>             elementFormDefault="qualified">
> 
>    <xs:element name="fsm">
>      <xs:complexType>
>        <xs:sequence>
>          <xs:element name="process" maxOccurs="unbounded">
>            <xs:complexType>
>              <xs:sequence>
>                <xs:element name="state" maxOccurs="unbounded">
>                  <xs:complexType>
>                    <xs:sequence>
>                      <xs:element ref="description" minOccurs="0"/>
>                      <xs:choice>
>                        <xs:element name="do-activity" type="xs:string"
>                                    minOccurs="0"/>
>                        <xs:element name="do-process" minOccurs="0">
>                          <xs:complexType>
>                            <xs:attribute name="name" type="xs:string"
>                                          use="required"/>
>                          </xs:complexType>
>                        </xs:element>
>                      </xs:choice>
>                    </xs:sequence>
>                    <xs:attribute name="name" use="required">
>                      <xs:simpleType>
>                        <xs:restriction base="xs:NMTOKEN"/>
>                      </xs:simpleType>
>                    </xs:attribute>
>                    <xs:attribute name="terminal" type="xs:boolean"/>
>                  </xs:complexType>
>                </xs:element>
>                <xs:element name="transition" maxOccurs="unbounded">
>                  <xs:complexType>
>                    <xs:sequence>
>                      <xs:element ref="description" minOccurs="0"/>
>                      <xs:element name="guard">
>                        <xs:complexType mixed="true">
>                          <xs:choice minOccurs="0">
>                            <xs:element name="fail">
>                              <xs:complexType/>
>                            </xs:element>
>                            <xs:element name="pass">
>                              <xs:complexType/>
>                            </xs:element>
>                          </xs:choice>
>                        </xs:complexType>
>                      </xs:element>
>                    </xs:sequence>
>                    <xs:attribute name="from" use="required">
>                      <xs:simpleType>
>                        <xs:restriction base="xs:NMTOKEN"/>
>                      </xs:simpleType>
>                    </xs:attribute>
>                    <xs:attribute name="to" use="required">
>                      <xs:simpleType>
>                        <xs:restriction base="xs:NMTOKEN"/>
>                      </xs:simpleType>
>                    </xs:attribute>
>                  </xs:complexType>
>                </xs:element>
>              </xs:sequence>
>              <xs:attribute name="name" type="xs:NMTOKEN" 
use="required"/>
>              <xs:attribute name="start" type="xs:NMTOKEN" 
use="required"/>
>            </xs:complexType>
>            <xs:key name="state-name-pk">
>              <xs:selector xpath="./state"/>
>              <xs:field xpath="@name"/>
>            </xs:key>
>            <xs:keyref name="sn1" refer="state-name-pk">
>              <xs:selector xpath="./transition"/>
>              <xs:field xpath="@from"/>
>            </xs:keyref>
>            <xs:keyref name="sn2" refer="state-name-pk">
>              <xs:selector xpath="./transition"/>
>              <xs:field xpath="@to"/>
>            </xs:keyref>
>            <xs:keyref name="sn3" refer="state-name-pk">
>              <xs:selector xpath="."/>
>              <xs:field xpath="@start"/>
>            </xs:keyref>
>          </xs:element>
>          <xs:element name="spawn-process">
>            <xs:complexType>
>              <xs:attribute name="name" type="xs:NMTOKEN" 
use="required"/>
>            </xs:complexType>
>          </xs:element>
>        </xs:sequence>
>        <xs:attribute name="trim" type="xs:boolean" use="required"/>
>      </xs:complexType>
>      <xs:key name="process-name-pk">
>        <xs:selector xpath="./process"/>
>        <xs:field xpath="@name"/>
>      </xs:key>
>      <xs:keyref name="process-name-fk1" refer="process-name-pk">
>        <xs:selector xpath="./spawn-process"/>
>        <xs:field xpath="@name"/>
>      </xs:keyref>
>    </xs:element>
>    <xs:element name="description" type="xs:string"/>
> 
> </xs:schema>
> 
> -- 
> Guy Thomas                                    [EMAIL PROTECTED]
> fks bvba - Formal and Knowledge Systems       http://www.fks.be/
> Stationsstraat 108                            Tel:  ++32-(0)11-21 49 11
> B-3570 ALKEN                                  Fax:  ++32-(0)11-22 04 19
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED] 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to