Parsing XSD using Xerces - parsing

I need to parse a generic XSD and create sample XMLs conforming to the XSD. I am using Xerces for Java.
Does Xerces provide support for parsing XSD or do i have to parse it as a regular XML ? If theres support in Xerces, how do i do it?
Also could someone point to way/technique by which i can create all possible XMLs conforming to an XSD.
if possible please share code link or code snippet.
Thanks.

I am not sure which programming language you want to use but assuming Java, you can use XSOM or JaxMe to parse XSD's. You can extract the schema information and then generate the xml's based on the parsed meta data. Or check if XIG: Xml Instance Generator meets your requirement.

Related

Is Saxon susceptible to XXE attacks?

When we load an XML file to then make XPath 2.0 queries on it, will an XXE file in the XML be processed?
And if so, is there any way to turn that off?
XXE is an XML parser vulnerability and Saxon does not do XML parsing itself, it invokes whatever parser you configure it to use (there are defaults of course). You have full control over what XML parser Saxon uses and how that parser is configured. Details depend on what platform and API you are using.

Convert Swagger JSON to AsciiDoc markdown

I'm trying to import Swagger JSON into AsciiDoc. To do that I'm trying to convert the Swagger JSON into markdown that can be read by AsciiDoc. I can't figure out how to do it. I've read that I will likely need to use swagger2markup. However, not being a Java programmer it's unclear how to use this. I got some clues from this answer but I can't get very far. It involves using J Unit and I don't know what to do with that and all that is required. Has anyone figured out how to do this?
I got some help from a coworker on how to convert the my Swagger JSON to AsciiDoc markdown. The more complex instructions here were not what I needed. The CLI instructions here were. The simpler conversion process using the CLI as opposed to integrating Swagger2Markdown into a Java app were ideal.

Puppet: Is there any way to parse XML in puppet template file

I am now using json data to fill my puppet templates. I want know that is there any way to parse a xml inside puppet template.
Also there is an additional issue. I am using external facts to take data from the agent to the master. Basically what I am doing is taking my data as a string and parse it to a json inside my template. I want to parse my string into xml ( I will send data in correct format).
Regards,
Malintha
Puppet has no native XML support.
As for the eRuby templates - those appear to require external libraries to deserialize XML.

Clarification needed about generating jax-ws client stubs in order to consume a webservice

I have on the one hand a wsdl url/file and on the other hand a number of xsd schema files (are the latte called binding files?).
All of these describe a webservice that I would like to consume using jax-ws.
I understand I need to generate client stubs using the wsimport utility.
I have a requirement for one distinct package per xsd schema/binding file for the generated stubs files. The generated stubs for the wsdl would be located in another package.
Does that make sense?
Is this possible? If so how?
I am missing something?
edit: I don't fully understand the difference of intent between files generated against the wsdl and files generated against the xsd binding files as when using wsimport. Can someone please explain?
baleto
first thing the xjb files are used to resolve conflicts and customizing schemas.
You can create a distinct package for a XSD if it has a specfic namespace defined for it.
For example you need a package name like com.foo.healthcare.claims then you need to have a name space for the schema as http://www.foo.com/healthcare/claims.

XMl Data into String in blackberry

Read the contents of an local XML file in an application and get the whole contents of xml file into a string for blackberry application?
To create a string from a local file see this blackberry forum entry: Open txt file from mediacard
Assuming you want to use the data within the XML, I would recommend using a XML parser rather than string manipulation. The following links should get you going with XML parsers and explain some of the trade-offs:
Blackberry How To - Use the XML Parser
Parsing XML in J2ME
Add XML parsing to your J2ME applications
If, however, you have any say about the format used JSON might be a good alternative. JSON is easy for machines to parse (thus using fewer resources) and it's human readable.
I have found using a SAXParser and subclassing DefaultHandler has worked well. Allows to go element by element.

Resources