We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a need to convert XML to Avro and i am exploring this tool to achieve the same.
Xml Sample
<employee id="100"> <department id="1000">HR</department> </employee>
XSD
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="employee"> <xs:complexType> <xs:sequence> <xs:element name="department"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute type="xs:short" name="id"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute type="xs:byte" name="id"/> </xs:complexType> </xs:element> </xs:schema>
Code for the conversion
public static void main(String[] args) { Schema schema = Converter.createSchema(new File("employee.xsd")); GenericData.Record record = Converter.createDatum(schema, new File("employee.xml")); System.out.println(record.get("department")); System.out.println(record.get("employee")); }
Output
{"id": 1000} null
{"id": 1000}
null
Questions
The text was updated successfully, but these errors were encountered:
well you will have to loop through the attributes
Sorry, something went wrong.
No branches or pull requests
I have a need to convert XML to Avro and i am exploring this tool to achieve the same.
Xml Sample
XSD
Code for the conversion
Output
Questions
The text was updated successfully, but these errors were encountered: