{"id":970,"date":"2005-01-27T07:30:00","date_gmt":"2005-01-27T07:30:00","guid":{"rendered":"\/blogs\/bobb\/post\/Fun-with-static-XQuery-evaluation-3.aspx"},"modified":"2005-01-27T07:30:00","modified_gmt":"2005-01-27T07:30:00","slug":"fun-with-static-xquery-evaluation-3","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/","title":{"rendered":"Fun with static XQuery evaluation &#8211; 3"},"content":{"rendered":"<p>\nAfter the last two entries, you might be thinking &quot;I guess I can never use text() as a node test with typed XML again&quot;. Not so. The error message reads: &#39;text()&#39; is not supported on simple typed or &#39;http:\/\/www.w3.org\/2001\/XMLSchema#anyType&#39; elements. So what&#39;s left? Mixed content, for one thing. Mixed content consists of a mixture of text and also embedded subelements.\n<\/p>\n<p>\nIf we change the schema to allow mixed content (this schema also allows a particular subelement):\n<\/p>\n<p>\nCREATE XML SCHEMA COLLECTION mixedage AS<br \/>\n&#39;&lt;xs:schema<br \/>\nxmlns:xs=&quot;<a href=\"http:\/\/www.w3.org\/2001\/XMLSchema\" class=\"broken_link\">http:\/\/www.w3.org\/2001\/XMLSchema<\/a>&quot;<br \/>\ntargetNamespace=&quot;urn:ages&quot;<br \/>\nxmlns:tns=&quot;urn:ages&quot;&gt;<br \/>\n&nbsp; &lt;xs:complexType name=&quot;age&quot; mixed=&quot;true&quot;&gt;<br \/>\n&nbsp;&nbsp;&nbsp; &lt;xs:complexContent mixed=&quot;true&quot;&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:restriction base=&quot;xs:anyType&quot;&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:sequence&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name=&quot;dogyears&quot; type=&quot;xs:int&quot;\/&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/xs:sequence&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/xs:restriction&gt;<br \/>\n&nbsp;&nbsp;&nbsp; &lt;\/xs:complexContent&gt;<br \/>\n&nbsp; &lt;\/xs:complexType&gt;\n<\/p>\n<p>\n&lt;xs:element name=&quot;age&quot; type=&quot;tns:age&quot;\/&gt;<br \/>\n&lt;\/xs:schema&gt;<br \/>\n&#39;\n<\/p>\n<p>\nThen the text() node test works with typed XML just fine:\n<\/p>\n<p>\nDECLARE @x xml(mixedage)<br \/>\nSET @x = &#39;<br \/>\n&lt;ag:age xmlns:ag=&quot;urn:ages&quot;&gt;This is the age in dog years&lt;dogyears&gt;3&lt;\/dogyears&gt;&lt;\/ag:age&gt;&#39;<br \/>\n&#8212; now it works OK<br \/>\nSELECT @x.query(&#39;<br \/>\ndeclare default namespace &quot;urn:ages&quot;;<br \/>\n\/age\/text()&#39;)<br \/>\nGO<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After the last two entries, you might be thinking &quot;I guess I can never use text() as a node test with typed XML again&quot;. Not so. The error message reads: &#39;text()&#39; is not supported on simple typed or &#39;http:\/\/www.w3.org\/2001\/XMLSchema#anyType&#39; elements. So what&#39;s left? Mixed content, for one thing. Mixed content consists of a mixture of [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,37],"tags":[],"class_list":["post-970","post","type-post","status-publish","format-standard","hentry","category-sql-server-2005","category-sql-server-xml"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Fun with static XQuery evaluation - 3 - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fun with static XQuery evaluation - 3 - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"After the last two entries, you might be thinking &quot;I guess I can never use text() as a node test with typed XML again&quot;. Not so. The error message reads: &#039;text()&#039; is not supported on simple typed or &#039;http:\/\/www.w3.org\/2001\/XMLSchema#anyType&#039; elements. So what&#039;s left? Mixed content, for one thing. Mixed content consists of a mixture of [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2005-01-27T07:30:00+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/\",\"name\":\"Fun with static XQuery evaluation - 3 - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2005-01-27T07:30:00+00:00\",\"dateModified\":\"2005-01-27T07:30:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server 2005\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2005\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Fun with static XQuery evaluation &#8211; 3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fun with static XQuery evaluation - 3 - Bob Beauchemin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/","og_locale":"en_US","og_type":"article","og_title":"Fun with static XQuery evaluation - 3 - Bob Beauchemin","og_description":"After the last two entries, you might be thinking &quot;I guess I can never use text() as a node test with typed XML again&quot;. Not so. The error message reads: &#39;text()&#39; is not supported on simple typed or &#39;http:\/\/www.w3.org\/2001\/XMLSchema#anyType&#39; elements. So what&#39;s left? Mixed content, for one thing. Mixed content consists of a mixture of [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/","og_site_name":"Bob Beauchemin","article_published_time":"2005-01-27T07:30:00+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/","name":"Fun with static XQuery evaluation - 3 - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2005-01-27T07:30:00+00:00","dateModified":"2005-01-27T07:30:00+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/fun-with-static-xquery-evaluation-3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"SQL Server 2005","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2005\/"},{"@type":"ListItem","position":3,"name":"Fun with static XQuery evaluation &#8211; 3"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=970"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/970\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}