Simpler XQuery Syntax?



All:

In SQL 2005, I’ve got an XML column called ‘CurrentConfig’ in a table called
‘Computers’. I just added a second schema to the schema collection. The
initial schema had no associated namespace (i.e. the “no namespace”
namespace). I recently added an extended schema with the namespace,
‘urn:ConfigSchema_V2’. The second schema is similar to the first, but has
been extended and tightened down in certain areas.

Look at the query below and notice that the ‘for’ statements are identical;
the only difference is the namespace declaration in the second query. This
works as intended, but it seems like a more concise representation of this
whole statement would be possible. However, I couldn’t get the syntax gods
to cooperate. ;-)

Any simplification ideas?

Thanks,
Bill D.


SELECT ComputerName
from dbo.Computers
where
cast(CurrentConfig.query('

for $x in /CurrentConfiguration/Install/V
where string($x/@n) = "TIER_SERVER"
return data($x/@d)
') as varchar(1)) = '1'

Or

cast(CurrentConfig.query('
declare default element namespace "urn:ConfigSchema_V2";

for $x in /CurrentConfiguration/Install/V
where string($x/@n) = "TIER_SERVER"
return data($x/@d)
') as varchar(1)) = '1'
ORDER BY 1
FOR XML AUTO

.



Relevant Pages

  • RE: Simpler XQuery Syntax?
    ... "Bill D." ... I just added a second schema to the schema collection. ... I recently added an extended schema with the namespace, ...
    (microsoft.public.sqlserver.xml)
  • Re: Two different element types with the same name ?
    ... default namespace declaration and both A belong to the same namespace ... But of course you can also use recursion and define a schema like ... is also a valid instance of the second schema but now you can write other samples like ... which is also a valid instance of the second schema but of course not of the first one. ...
    (comp.text.xml)
  • Re: Two different element types with the same name ?
    ... I am currently reading "Definitive XML Schema" 2nd by Priscilla Walmsley so it makes sense. ... default namespace declaration and both A belong to the same namespace ... is also a valid instance of the second schema but now you can write other samples like ... which is also a valid instance of the second schema but of course not of the first one. ...
    (comp.text.xml)
  • Re: validating xml doc with multiple schemas using wildcards
    ... The second schema defines elements in the namespace ... You need to provide the locations of the schemas with schemaLocation, not with noNamespaceSchemaLocation e.g. ...
    (microsoft.public.dotnet.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)