Frage

Ich verwende asn1 Modul in erlang zu dekodieren. Der Ausgang ist wie

{'UL-CCCH-Message',asn1_NOVALUE,
               {rrcConnectionRequest,
                {'RRCConnectionRequest',
                 {'tmsi-and-LAI',
                  {'TMSI-and-LAI-GSM-MAP',
                   [1,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,0,1,1,0,1,1,0,1,0,1,1,
                    1,1,0,1,0],
                   {'LAI',
                    {'PLMN-Identity',[2,2,6],[0,1]},
                    [0,1,1,1,1,0,0,1,1,0,0,0,1,1,0,1]}}},
                 terminatingBackgroundCall,noError,
                 {'MeasuredResultsOnRACH',
                  {'MeasuredResultsOnRACH_currentCell',
                   {fdd,
                    {'MeasuredResultsOnRACH_currentCell_modeSpecificInfo_fdd',
                     {'cpich-Ec-N0',39}}}},
                  asn1_NOVALUE},
                 asn1_NOVALUE}}}

Wie kann ich XML-Ausgabe statt erlang Begriff?

War es hilfreich?

Lösung

Beachten Sie, dass jeder erlang Begriff (nicht spezifisch für die ASN.1-Modul) Ausgabe als XML durch eine Funktion wie diese leicht sein könnte:

to_xml(X) when is_atom(X) ->
    "<atom>" ++ atom_to_list(X) ++ "</atom>"; % might want apostrophes
to_xml(X) when is_integer(X) ->
    "<integer>" ++ io_lib:format("~p", [X]) ++ "</integer>";
to_xml(X) when is_tuple(X) ->
    "<tuple size=" ++ tuple_size(X) ++ ">" ++ % or maybe want size implicit
        lists:foldr(fun(E, L) -> to_xml(E) ++ L end, [], tuple_to_list(X))
        ++ "</tuple>";
to_xml(X) when is_list(X) ->
    "<list>" ++ lists:foldr(fun(E, L) -> to_xml(E) ++ L end, [], X) ++ "</list>";
% etc...

Andere Tipps

Vielleicht zwei verfügbare Option für Sie für ASN1 auf XML-Darstellung konvertieren:

http: //www.research. ibm.com/trl/projects/xml/xss4j/docs/axt-readme.html

http://www.obj-sys.com/webtools/asn2xml.php

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top