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 6386225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:59:51+00:00 2026-05-25T02:59:51+00:00

I have the following XML Schema: CREATE XML SCHEMA COLLECTION test AS ‘ <xsd:schema

  • 0

I have the following XML Schema:

CREATE XML SCHEMA COLLECTION test AS '
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="PointConf">
    <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="GlobalFlags">
              <xsd:complexType>
                    <xsd:sequence>
                      <xsd:element name="Order" type="OrderType"/>
                      <xsd:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
                    </xsd:sequence>
              </xsd:complexType>  
            </xsd:element>           
          </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:complexType name="OrderType">
    <xsd:attribute name="value" type="xsd:int" />
  </xsd:complexType>
</xsd:schema>
'
GO

Then I use it in this way:

DECLARE @xml xml(test)

SET @xml='<PointConf>
  <GlobalFlags>    
    <Order value="1" />
  </GlobalFlags>

</PointConf>'

SELECT @xml.value('(/PointConf/GlobalFlags/Order/@value)[1]','int')

SELECT gives me the following error:

XQuery [value()]: 'value()' requires a singleton (or empty sequence), found operand of type '(xs:int | xdt:anyAtomicType *) ?'

Without the xsd:any element in the schema the code above works without any errors. What am I doing wrong?

  • 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-25T02:59:52+00:00Added an answer on May 25, 2026 at 2:59 am

    I got the select to work by using the statement

    SELECT @xml.value('string(/PointConf[1]/GlobalFlags/Order[1]/@value)','int')
    

    I understand the requirement for the [1] index on the Order node, as this can be a list, however I don’t see why its required for the PointConf node.

    The [1] needs to be used at the actual level where a list exists to restrict that list to a single return value

    The string(...) turns the node set into a string (or empty string). I think this helps with the xsd:any although I’m not completely sure why – something to do with handling the possibility of the node Order being missing completely I think.


    Update:

    Investigating further:

    SELECT @xml.value('string((/PointConf/GlobalFlags/Order/@value)[1])','int')

    also works.

    So its just the string function that’s required to make it work in this instance.

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

Sidebar

Related Questions

I have the following start of an XSD: <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns:no=http://www.sychophants.com>
We have this XML schema: <xs:schema attributeFormDefault=unqualified elementFormDefault=qualified xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=Log> <xs:complexType> <xs:sequence minOccurs=0
I have a scheme that looks like <?xml version=1.0 ?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=RequestResponseBase
Lets say I have the following XML file: <?xml version=1.0 encoding=utf-8?> <Customers xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=Customer.xsd>
I have created the following vsct file xml. <?xml version=1.0 encoding=utf-8?> <CommandTable xmlns=http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable xmlns:xs=http://www.w3.org/2001/XMLSchema>
I have the following XML layout for a ListActivity. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
Is it possible to create an XML schema with the following behavior? I have
I have run across an XML Schema with the following definition: <xs:simpleType name=ClassRankType> <xs:restriction
I have the following XML <?xml version=1.0?> <FileHeader xmlns=urn:schemas-ncr-com:ECPIX:CXF:FileStructure:020001 VersionNumber=020001 TestFileIndicator=P CreationDate=13012009 CreationTime=172852 FileID=0000000001
I have XSD Schema with the following structure: ElementA has only one ElementB and

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.