Re: XML XPath problem

Tech-Archive recommends: Speed Up your PC by fixing your registry



The problem is that your schema allows /i:analysis/i:cube to produce more than one element. To resolve your predicate XQuery in effect does

string(/i:analysis/i:cube)

and is unhappy becase it looks at the schema and finds that more than one cube is possible. I think what you want to see if any cube contains "Customers". Here is a slight change to your query that does that.

XS2 is the XML SCHEMA COLLECTION that contains your schema.

CREATE TABLE bookmark
(
BookmarkID int identity primary key,
BookmarkDoc xml(XS2)
)


INSERT INTO bookmark VALUES ('
<i:analysis xmlns:i="http://activeinterface.com/intrasight";>
<i:catalog>asdf</i:catalog>
<i:cube>asdfadsf</i:cube>
<i:properties>
<i:Title rows="1"/>
<i:Description rows="1"/>
<i:Notes rows="9"/>
</i:properties>
<i:cube>Customers</i:cube>
</i:analysis>'
)


SELECT BookmarkID, BookmarkDoc FROM bookmark
WHERE BookmarkDoc.exist('declare namespace i="http://activeinterface.com/intrasight";;

/i:analysis[i:cube[string()=''Customers'']]') = 1
GO

BTW XQuery in SQL Server does static analysis, i.e. it looks at the schema if there is one, before it even tries to execute the query. if you were not using a schema it wouldn't be a problem.

Dan


Brandon,

Thanks for replying - this really has me stumped.

I figured it was getting stuck on those escaped single quotes around
'Customers' or square brackets. But if the TSQL looks ok, then perhaps
it is
a schema issue.
Here is the schema (note that in my original posting that I had not
used
actual namespace)
<?xml version="1.0" encoding="iso-8859-1"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns="http://activeinterface.com/intrasight";
targetNamespace="http://activeinterface.com/intrasight";
elementFormDefault="qualified" >
<xsd:annotation>
<xsd:documentation>
This is the simplified schema for Intrasight GUI XML serialization
</xsd:documentation>
</xsd:annotation>
<xsd:complexType name="PropType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="rows" type="xsd:int" use="required" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:element name="analysis">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="catalog" type="xsd:string" />
<xsd:element name="cube" type="xsd:string" />
<xsd:element name="properties">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Title" type="PropType" />
<xsd:element name="Description" type="PropType" />
<xsd:element name="Notes" type="PropType" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:any processContents="skip" namespace="##targetNamespace"
minOccurs="1" maxOccurs="unbounded"></xsd:any>

</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

"Brandon Berg [MSFT]" <branber@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:44a04cfc$1@xxxxxxxxxxxxxxxxxxxxx

"ChrisHarrington" <charrington-at-activeinterface.com> wrote in
message news:OesF7PVmGHA.4212@xxxxxxxxxxxxxxxxxxxxxxx

This TSQL

SELECT BookmarkID FROM bookmark
WHERE BookmarkDoc.exist('declare namespace i="http://mynamespace";;
/i:analysis[i:cube=''Customers'']') = 1
GO
return error:

Msg 9311, Level 16, State 1, Line 4
XQuery [bookmark.BookmarkDoc.exist()]: Heterogeneous sequences are
not
allowed in '=', found 'xdt:untypedAtomic' and 'xs:string'.
How does one properly express such things in TSQL?

The T-SQL's fine--the problem is with the XQuery. What is the schema
for i:analysis?

--
Brandon Berg
Software Design Engineer
Microsoft SQL Server


.



Relevant Pages

  • Re: SQL Server 2005 XML: Namespaces Not Being Hit/Used
    ... XQuery and XML is a purely syntactic way of having to avoid to write ... we currently only provide schema collections and since ... That's why you still need the namespace declaration syntax. ...
    (microsoft.public.sqlserver.xml)
  • Re: XML XPath problem
    ... XS2 is the XML SCHEMA COLLECTION that contains your schema. ... INSERT INTO bookmark VALUES (' ... WHERE BookmarkDoc.exist('declare namespace ... BTW XQuery in SQL Server does static analysis, i.e. it looks at the schema ...
    (microsoft.public.sqlserver.xml)
  • Re: Flat File Problem
    ... It was the namespace I was using to ... When I debug the orchestration the RecCount variable is null. ... Have you deployed the Biztalk Assembly that contains the property schema ... And you can promote properties from the Header into the message context, ...
    (microsoft.public.biztalk.general)
  • Schema versioning / namespace or no namespace / like root nodes / Pipelines - any ideas?
    ... Namespace Options: Trying to figure out which way to go... ... I'm planning to handle the varying levels of schema content being ... Pipeline component to add this namespace to incoming SAP docs. ... pipeline per assembly-version (since there's no need for the pipeline ...
    (microsoft.public.biztalk.general)
  • Re: Re: Re: SQLXML Namespaces
    ... > namespace, so SQLXML has declared an arbitrary prefix for the ... > the results you can declare any prefix you like and the XML ... >> Your schema must have a default or target namespace ...
    (microsoft.public.sqlserver.xml)