title: ISO20022 message schema Node search for specified path
body: <p>I have path for an element in XSD as string as &quot;Document.FIToFIPmtStsRpt.GrpHdr.InstgAgt.FinInstnId.PstlAdr.AdrTp.Cd&quot;. Now i want to reach to that path's node but the problem is coming while getting node at specified path. i have used XPath(javax.xml.xpath) to find the node which takes path but in path sequence and choice tags are used interchangeably. I am also unable to understand the xs:sequence and xs:choice. i am able to reach to the node if it is xs:sequence but not able to reach xs:choice node.
  I am using XPath like this.</p>
  <pre><code>DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
              documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, &quot;&quot;);
              documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, &quot;&quot;);
              document = documentBuilderFactory.newDocumentBuilder().parse(new InputSource(userXSDFile.getAbsolutePath()));
          StringBuilder expression = new StringBuilder();
  if (nodes == null) {
                  expression.append(&quot;/schema/complexType[@name=&quot;);
                  expression.append(&quot;\&quot;&quot;);
                  expression.append(userValidation.getPath().split(&quot;\\.&quot;)[0]);
                  expression.append(&quot;\&quot;&quot;);
                  expression.append(&quot;]&quot;);
                  expression.append(&quot;/sequence/element[@name=&quot;);
                  expression.append(&quot;\&quot;&quot;);
                  expression.append(userValidation.getPath().split(&quot;\\.&quot;)[1]);
                  expression.append(&quot;\&quot;&quot;);
                  expression.append(&quot;]&quot;);
                  // use xpath to find node
                  XPath xPath = XPathFactory.newInstance().newXPath();
                  nodes = (NodeList) xPath.evaluate(String.valueOf(expression), document.getDocumentElement(), XPathConstants.NODESET);
              }
  </code></pre>
  <p>I am trying to reach to element &quot;Cd&quot; type &quot;AddressType2Code&quot;</p>
  <pre><code>xsd :-  &lt;xs:simpleType name=&quot;AddressType2Code&quot;&gt;
          &lt;xs:restriction base=&quot;xs:string&quot;&gt;
              &lt;xs:enumeration value=&quot;ADDR&quot;/&gt;
              &lt;xs:enumeration value=&quot;PBOX&quot;/&gt;
              &lt;xs:enumeration value=&quot;HOME&quot;/&gt;
              &lt;xs:enumeration value=&quot;BIZZ&quot;/&gt;
              &lt;xs:enumeration value=&quot;MLTO&quot;/&gt;
              &lt;xs:enumeration value=&quot;DLVY&quot;/&gt;
          &lt;/xs:restriction&gt;
      &lt;/xs:simpleType&gt;
      &lt;xs:complexType name=&quot;AddressType3Choice&quot;&gt;
          &lt;xs:choice&gt;
              &lt;xs:element name=&quot;Cd&quot; type=&quot;AddressType2Code&quot;/&gt;
              &lt;xs:element name=&quot;Prtry&quot; type=&quot;GenericIdentification30&quot;/&gt;
          &lt;/xs:choice&gt;
      &lt;/xs:complexType&gt;
  </code></pre>