<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello Erlang experts,</p>
    <p>I'm having  a problem trying to parse some XML using the
      excellent erlsom tool, I don't know if it's me, erlsom, XML, XSD
      or something else that's giving me issues.</p>
    <p>The XML I'm trying to parse looks like this and the problem I
      have is with the xsi:type attribute on the Value element, oh and
      by the way, I can't change the XML as it coming from a 3rd party.<br>
    </p>
    <p><tt><soap:Envelope xmlns:cwmp="urn:dslforum-org:cwmp-1-0"</tt><tt><br>
      </tt><tt>              
        xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a></tt><tt><br>
      </tt><tt>              
        xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a></tt><tt><br>
      </tt><tt>              
        xmlns:soap=<a class="moz-txt-link-rfc2396E" href="http://schemas.xmlsoap.org/soap/envelope/">"http://schemas.xmlsoap.org/soap/envelope/"</a></tt><tt><br>
      </tt><tt>              
        xmlns:soap-enc=<a class="moz-txt-link-rfc2396E" href="http://schemas.xmlsoap.org/soap/encoding/">"http://schemas.xmlsoap.org/soap/encoding/"</a>></tt><tt><br>
      </tt><tt><soap:Header></tt><tt><br>
      </tt><tt><cwmp:ID
        soap:mustUnderstand="1">1410271757429_7070_2008420083</cwmp:ID></tt><tt><br>
      </tt><tt></soap:Header></tt><tt><br>
      </tt><tt><soap:Body></tt><tt><br>
      </tt><tt><cwmp:SetParameterValues></tt><tt><br>
      </tt><tt><ParameterList
        soap-enc:arrayType="cwmp:ParameterValueStruct[1]"></tt><tt><br>
      </tt><tt><ParameterValueStruct></tt><tt><br>
      </tt><tt><Name>Device.ManagementServer.URL</Name></tt><tt><br>
      </tt><tt><Value <span style="background-color:#ff6;">xsi:type="xsd:string"</span>><a class="moz-txt-link-freetext" href="http://10.255.249.122/acs">http://10.255.249.122/acs</a></Value></tt><tt><br>
      </tt><tt></ParameterValueStruct></tt><tt><br>
      </tt><tt></ParameterList></tt><tt><br>
      </tt><tt><ParameterKey>1155965801</ParameterKey></tt><tt><br>
      </tt><tt></cwmp:SetParameterValues></tt><tt><br>
      </tt><tt></soap:Body></tt><tt><br>
      </tt><tt></soap:Envelope></tt><br>
    </p>
    <p>The error I get is:</p>
    <p><tt>34> erlsom:scan_file(Xml, ModelIn).</tt><tt><br>
      </tt><tt>{error,[{exception,{error,"Type not found in hierarchy:
        in:ValueElement"}},</tt><tt><br>
      </tt><tt>       
        {stack,['in:ParameterValueStruct','in:ParameterValueList',</tt><tt><br>
      </tt><tt>               
        'in:SetParameterValues','P:Body','P:Envelope']},</tt><tt><br>
      </tt><tt>        {received,{startElement,[],"Value",[],</tt><tt><br>
      </tt><tt>                                [{attribute,"type","xsi",</tt><tt><br>
      </tt><tt>                                           
        <a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>,</tt><tt><br>
      </tt><tt>                                           
        "xsd:string"}]}}]}</tt><br>
      <br>
    </p>
    The XSD I'm using is here: <a class="moz-txt-link-freetext" href="https://pastebin.com/VrBx0j0f">https://pastebin.com/VrBx0j0f</a><br>
    It is based of the the standard TR069 XSD but I had to modify it to
    make the Value element a complexType in order to add the attribute.<br>
    <br>
    Value was defined as <br>
    <br>
    <tt>  <xs:element name="Value" type="xs:anySimpleType"/></tt><br>
    <br>
    and is now defined as <br>
    <br>
    <tt>  <xs:complexType name="ValueElement"></tt><tt><br>
    </tt><tt>    <xs:simpleContent></tt><tt><br>
    </tt><tt>      <xs:extension base="xs:anySimpleType"></tt><tt><br>
    </tt><tt>        <xs:attribute name="xsi:type"
      type="xs:string"></tt><tt><br>
    </tt><tt>        </xs:attribute></tt><tt><br>
    </tt><tt>      </xs:extension></tt><tt><br>
    </tt><tt>    </xs:simpleContent></tt><tt><br>
    </tt><tt>  </xs:complexType></tt><br>
    <br>
    <br>
    A session showing the problem is here: <a class="moz-txt-link-freetext" href="https://pastebin.com/APSLK4ry">https://pastebin.com/APSLK4ry</a><br>
    <p>Many thanks for reading this far.<br>
    </p>
    <p>Thanks</p>
    <p>Alan<br>
    </p>
  <div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br />
<table style="border-top: 1px solid #D3D4DE;">
        <tr>
        <td style="width: 55px; padding-top: 13px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
                <td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avast.com</a>
                </td>
        </tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>