Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 686901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:04:18+00:00 2026-05-14T02:04:18+00:00

I try to refer with an xsd:keyref from within a node/subnode structure to a

  • 0

I try to refer with an xsd:keyref from within a node/subnode structure to a global table that is child of the xml root element.

Here is an example xml

<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns="http://www.example.org/keyTest"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/keyTest keyTest.xsd">

<Globals key="key1"/>   
<Globals key="key2"/>
<Globals key="key3"/>

<Node>
<SubNode keyref="key2"/>
<SubNode keyref="key3"/>    
<SubNode keyref="key1">
    <SubNode keyref="key2">
        <SubNode keyref="key1"/>
    </SubNode>  
</SubNode>      
</Node>
</Root>

I also have an xsd defining the xsd:key and xsd:keyref fields within the document. These keys should verify that all keyref values are within the global table at the start of the xml document. Up to now I haven’t figured out what the problem with the selector xpath expression could be.

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" 
        targetNamespace="http://www.example.org/keyTest" 
        xmlns:tns="http://www.example.org/keyTest" 
        elementFormDefault="qualified">

<complexType name="Global">
    <attribute name="key" type="string"/>
</complexType>

<complexType name="Node" >
    <sequence maxOccurs="unbounded">
        <element name="SubNode" type="tns:Node" minOccurs="0"/>
    </sequence>
    <attribute name="keyref" type="string"/>
</complexType>

<complexType name="Root">
    <sequence>
        <element name="Globals" type="tns:Global" maxOccurs="unbounded"/>
        <element name="Node" type="tns:Node" maxOccurs="1"/>
    </sequence>
</complexType>

<element name="Root" type="tns:Root">
    <key name="key">
        <selector xpath="Global"/>
        <field xpath="@key"></field>
    </key>
    <keyref name="keyref" refer="tns:key">
        <selector xpath="//SubNode"/>
        <field xpath="@keyref"/>
    </keyref>
</element>

The Problem is that xmllint issues that “//SubNode” cannot be compiled

keyTest.xsd:30: element selector: Schemas parser error :
       Element '{http://www.w3.org/2001/XMLSchema}selector', at
       atribute 'xpath': The XPath expression '//SubNode' could not be compiled.
       WXS schema keyTest.xsd failed to compile

When I try the xpath expression with an xpath validator it selects all subnodes within the document as defined in the W3C standard, so why is this xpath not working within the selector expression?

I also tried .//SubNode. This compiles correctly but don’t fail to validate if I enter a wrong keyref.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:04:19+00:00Added an answer on May 14, 2026 at 2:04 am

    I like to share the solution I found.

    The correct xsd is like this the namespace was missing:

    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" 
            targetNamespace="http://www.example.org/keyTest"   
            xmlns:tns="http://www.example.org/keyTest" 
            elementFormDefault="qualified">
    
    <complexType name="Global">
        <attribute name="key" type="string"/>
    </complexType>
    
    <complexType name="Node" >
        <sequence maxOccurs="unbounded">
            <element name="SubNode" type="tns:Node" minOccurs="0"/>
        </sequence>
        <attribute name="keyref" type="string"/>
    </complexType>
    
    <complexType name="Root">
        <sequence>
            <element name="Globals" type="tns:Global" maxOccurs="unbounded"/>
            <element name="Node" type="tns:Node" maxOccurs="1"/>
        </sequence>
    </complexType>
    
    <element name="Root" type="tns:Root">
        <key name="key">
            <selector xpath=".//tns:Globals"/>
            <field xpath="@key"></field>
        </key>
        <keyref name="keyref" refer="tns:key">
            <selector xpath=".//tns:SubNode"/>
            <field xpath="@keyref"/>
        </keyref>
        <unique name="uniqKey">
            <selector xpath=".//tns:Globals"/>
            <field xpath="@key"/>
        </unique>
    </element>
    

    Thanks to anybody started to work on this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m try to do something like that: Select column_name*other_column_name as sqr From table
I try to install this phonegap plugin from github , but when I refer
I want to download image from internet :: I refer this and try this
I try to refer to an array in the Game1 class by creating an
I have some cleanup code which may try to refer to an (stateful) EJB
Suppose I need to refer to the path C:\meshes\as . If I try writing
I need to check if a certain property exists within a class. Please refer
Given the following xml-snippet: <Environment> ... <MySqlConfiguration> <ActiveServer>1@db1</ActiveServer> <PassiveServer>2@db1</PassiveServer> <Replicate from=1@db1 to=2@db1 /> <Replicate
You can refer to this post of mine. It is not the case that,
Refer below code public void acquire(){ synchronized(a){ print(acquire()); try{ //Thread.sleep(5000); synchronized(this){ wait(5000); } print(I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.