Pergunta

I'm seeking for an efficient way to handle xml data on a embedded device with heavily limited performance factors (RAM and CPU). XML has the advantage that it can be easily handled by computer based Software Tools. Once the data is modeled and loaded to the embedded device it remains static.

I think that binary XML-Representation is the way to go. But which conversion standard should I follow, or shall I even create something completely new?

Requirements:

  • Clear Encoding rules and thus a deterministic binary format as result
  • Effective Random Access to binary Data (Next Element)
  • Easy access through C-Data-Structures

Example Data:

<Employee>
<Name>
    <GivenName>Gaston</GivenName>
    <FamilyName>Lagaffe<FamilyName>
</Name>
<innovation> 
    <description>Cosmo-coucou : horloge murale imitant la cabine Apollo </description>
    <drawing>604</drawing>
</innovation>
<innovation> 
    <description>Parapluie simulateur de beau temps </description> 
    <drawing>648</drawing>
</innovation>

Finally the ability to easily treat this binary data with C, such as extracting data into structs etc. is the most important requirement to comply with.

struct Employee {
   name *name;
   innovation *inovations;
};

struct name {
    char *GivenName;
    char *FamilyName;
};

struct innovation {
    char *Description;
    int  drawing;
};

Can asn1c help me with this?

Could the use of ASN.1 encoding rules do the job?

What's your experience with binary XML-data on embedded devices?

Foi útil?

Solução

If your XML data is described by an XML schema, you can automatically convert the XML schema to ASN.1 by using a tool based on X.694 (http://www.itu.int/ITU-T/recommendations/rec.aspx?rec=9612&lang=en) such as the one provided by OSS Nokalva (http://www.oss.com/xml/products/xsdasn1/xsdasn1.html). You can then use an ASN.1 tool to generate C structures from the resulting ASN.1 schema and then encode/decode your messages in BER, DER, or PER.
If you follow this procedure strictly, you will also be able to encode and decode XML data conforming to the original XML schema, by applying the Extended XML Encoding Rules of ASN.1 (E-XER) to your data.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top