title: query xml using xsd attributes
body: <p>I have an XML document that includes an inline XSD (shown fully below). the problem is that i need to search the XML content using attributes imputed from the XSD - preferably in LINQ (XPATH also works). </p>
  
  <p>So, in the example below, I would want to find the element <code>CATALOG_NAME</code> by inferring off the XSD the <code>sql:field</code> attribute value <code>CATALOG_NAME</code> and then matching it against the real element name in the XML document <code>CATALOG_NAMEC00</code>. Once I have the element, I want its value. </p>
  
  <p>I see numerous examples of XSD validation and examples of querying the XSD itself. In the end, I am looking for the "merged" capability without some manual lookup hack. </p>
  
  <p>Is this possible?</p>
  
  <pre><code>&lt;return xmlns="urn:schemas-microsoft-com:xml-analysis"&gt;
    &lt;root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msxmla="http://schemas.microsoft.com/analysisservices/2003/xmla"&gt;
      &lt;xsd:schema targetNamespace="urn:schemas-microsoft-com:xml-analysis:rowset" xmlns:sql="urn:schemas-microsoft-com:xml-sql" elementFormDefault="qualified"&gt;
        &lt;xsd:element name="root"&gt;
          &lt;xsd:complexType&gt;
            &lt;xsd:sequence minOccurs="0" maxOccurs="unbounded"&gt;
              &lt;xsd:element name="row" type="row" /&gt;
            &lt;/xsd:sequence&gt;
          &lt;/xsd:complexType&gt;
        &lt;/xsd:element&gt;
        &lt;xsd:simpleType name="uuid"&gt;
          &lt;xsd:restriction base="xsd:string"&gt;
            &lt;xsd:pattern value="[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}" /&gt;
          &lt;/xsd:restriction&gt;
        &lt;/xsd:simpleType&gt;
        &lt;xsd:complexType name="xmlDocument"&gt;
          &lt;xsd:sequence&gt;
            &lt;xsd:any /&gt;
          &lt;/xsd:sequence&gt;
        &lt;/xsd:complexType&gt;
        &lt;xsd:complexType name="row"&gt;
          &lt;xsd:sequence&gt;
            &lt;xsd:element sql:field="CATALOG_NAME" name="CATALOG_NAMEC00" type="xsd:string" minOccurs="0" /&gt;
            &lt;xsd:element sql:field="SCHEMA_NAME" name="SCHEMA_NAMEC01" type="xsd:string" minOccurs="0" /&gt;
            &lt;xsd:element sql:field="CUBE_NAME" name="CUBE_NAMEC02" type="xsd:string" minOccurs="0" /&gt;
            &lt;xsd:element sql:field="DIMENSION_UNIQUE_NAME" name="DIMENSION_UNIQUE_NAMEC03" type="xsd:string" minOccurs="0" /&gt;
            &lt;xsd:element sql:field="HIERARCHY_UNIQUE_NAME" name="HIERARCHY_UNIQUE_NAMEC04" type="xsd:string" minOccurs="0" /&gt;
          &lt;/xsd:sequence&gt;
        &lt;/xsd:complexType&gt;
      &lt;/xsd:schema&gt;
      &lt;row&gt;
        &lt;CATALOG_NAMEC00&gt;AGS PLANUNG_PA&lt;/CATALOG_NAMEC00&gt;
        &lt;CUBE_NAMEC02&gt;Aktionsplan&lt;/CUBE_NAMEC02&gt;
        &lt;DIMENSION_UNIQUE_NAMEC03&gt;[Planstand]&lt;/DIMENSION_UNIQUE_NAMEC03&gt;
        &lt;HIERARCHY_UNIQUE_NAMEC04&gt;[Planstand].[Planstand]&lt;/HIERARCHY_UNIQUE_NAMEC04&gt;
      &lt;/row&gt;
    &lt;/root&gt;
  &lt;/return&gt;
  </code></pre>