This project defines how XML syntax will be parsed. The parser org.openptk.structure.XmlConverter is bi-directional. It can "decode" an XML String into a hierarchy of OpenPTK Structures. It can also "encode" a hierarchy of OpenPTK Structures into a XML String.
This project uses the Java XML Stream XMLStreamReader and XMLStreamWriter Release 2.2
ImplementationThe attribute "categories" (identified above) need to implemented using the OpenPTK StructureIF interface.
ConfigurationThe following sample Converter configuration data indicates which XML elements support multi-values are its value element names are defined. <Converter type="xml" classname="org.openptk.structure.XmlConverter"> <Structures> <Structure id="subjects"> <Properties> <Property name="multivalue" value="subject"/> </Properties> </Structure> <Structure id="forgottenPasswordAnswers"> <Properties> <Property name="multivalue" value="answer"/> </Properties> </Structure> <Structure id="forgottenPasswordQuestions"> <Properties> <Property name="multivalue" value="question"/> </Properties> </Structure> <Structure id="roles"> <Properties> <Property name="multivalue" value="role"/> </Properties> </Structure> </Structures> </Converter> ExampleThis is a String representation, toString(), of a Structure hierarchy
subject={ uniqueid="cuser"; attributes={ empno=123456; active=true; lastname="User"; forgottenPasswordAnswers=[]; title="Jersey (JSR-311) Expert"; forgottenPasswordQuestions=[ "Mothers Maiden Name", "City you were born", "Last 4 digits of Frequent Flyer" ]; firstname="Curl"; telephone="123-456-7890"; email="restful@openptk.org"; manager="owner"; roles=["user","admin","operator"]; fullname="Curl User"; organization="openptk"; manager=42L } } Here is the encode XML output <subject> <uniqueid type="string">cuser</uniqueid> <attributes> <empno type="integer">123456</empno> <active type="boolean">true</active> <lastname type="string">User</lastname> <forgottenPasswordAnswers type="string"></forgottenPasswordAnswers> <title type="string">Jersey (JSR-311) Expert</title> <forgottenPasswordQuestions type="string"> <question>Mothers Maiden Name</question> <question>City you were born</question> <question>Last 4 digits of Frequent Flyer</question> </forgottenPasswordQuestions> <firstname type="string">Curl</firstname> <telephone type="string">123-456-7890</telephone> <email type="string">restful@openptk.org</email> <manager type="string">owner</manager> <roles type="string"> <role>user</role> <role>admin</role> <role>operator</role> </roles> <fullname type="string">Curl User</fullname> <organization type="string">openptk</organization> <manager type="long">42</manager> </attributes> </subject> |
Projects >