Menu

#2 xsd:attributeGroup problem

open
nobody
None
5
2009-07-02
2009-07-02
No

When using an xsd:attributeGroup inside a xml element, the order of the attributes of the group in a generated .hrl file does not match the order of the attributes when using erlsom:scan/2 or erlsom:write/2.

XSD Example test.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="attrinfo">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attributeGroup ref="_DefaultAttributes"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:attributeGroup name="_DefaultAttributes">
<xsd:attribute name="a" type="xsd:string"/>
<xsd:attribute name="b" type="xsd:string"/>
<xsd:attribute name="c" type="xsd:string"/>
</xsd:attributeGroup>
</xsd:schema>

XML Example test.xml:
<?xml version='1.0' encoding='UTF-8'?>
<attrinfo a ='a' c='c' Z="Z" b='b' x0="0"/>

Create test.hrl:
erl -eval 'erlsom:write_xsd_hrl_file("test.xsd","test.hrl")' -s erlang halt

Erlang code Example test.erl:
-module(test).
-export([bug/0]).
-include("test.hrl").
bug() ->
{ok, Model} = erlsom:compile_xsd_file("test.xsd"),
{ok, Xml} = file:read_file("test.xml"),
{ok, Result, _R} = erlsom:scan(Xml, Model),
io:format("a=~p b=~p c=~p~n", [Result#attrinfo.a, Result#attrinfo.b, Result#attrinfo.c]).

Result:
a="c" b="b" c="a"

The attached patch fixes this problem.

Discussion

  • Thomas Geffert

    Thomas Geffert - 2009-07-02

    patches xsd:attributeGroup handling

     
  • Willem de Jong

    Willem de Jong - 2010-01-31

    I fixed this (finally...). The fix is in the github repository, together with some other improvements - http://github.com/willemdj/erlsom.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.