SchemaLocation in JIBX generated xml - jibx

I am generating xml from Java object using JIBX. I want schemalocation to be set in generated xml. I am able to put namespace but but schemaLocation. Anyone has one idea how to do it?

You should be able to do this as an attribute value on the root element of your output document, along these lines:
<value name="schemaLocation" ns="http://www.w3.org/2001/XMLSchema" field="locationField"/>

Related

How can i remove a XML Element on JSON schema generated by swagger

I'm looking to generate a JSON schema from model (java) with swagger.
Actually shown on swagger a XML Element (don't need it)
i want remove it without remove annotation like #XmlElement or #XmlType
Must be like this one:
Exactly i need to remove this part (XML Representing):
enter link description here

WSO2 data service and data mapper

I am trying to apply the data mapper mediator to the output of the XML data service defined within WSO2EI. Documentation indicates, that to use the data mapper you need to have a fully qualified names in the XML input files.
The data service I am creating does not include qualified prefixes within the XML it generates.
I tried to export the XSLT data mapping from the CAR file and run it along the sample XML generated by the data service through the external XML transformer - it did not work. However, if I added qualified prefixes in the input XML manually, everything works fine.
It seems that the reason for my data mapper not working is the default, and not qualified, namespace in the input XML. Unfortunately, I cannot get the data service including namespace prexifes in its output. Any ideas?
To illustrate the nature of the problem let us consider two slightly different inputs; first XML input file uses the default names, second one qualified names:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<users xmlns="http://ws.wso2.org/dataservice">
<user>
<last>Waelchi</last>
<first>Xzavier</first>
<country>Swaziland</country>
</user>
</users>
</soapenv:Body>
</soapenv:Envelope>
This XML is not properly handled by the XSLT, no matter if within WSO2EI, or external XML processor. However, the same XML with qualified names:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<users xmlns:p="http://ws.wso2.org/dataservice">
<p:user>
<p:last>Waelchi</p:last>
<p:first>Xzavier</p:first>
<p:country>Swaziland</p:country>
</p:user>
</users>
</soapenv:Body>
</soapenv:Envelope>
is properly interpreted at least by the external XML processor. My problem is, that I cannot get WSO2EI data service to include qualified prefixes in its output.
OK, I have managed to bypass the problem transforming XML output by WSO2 data service into qualified XML using XSLT transform. However, I am still unable to get qualified XML directly from the data service; any suggestion shall be appreciated.

How to omit fields when using camel-xmljson JAR to convert XML string to JSON string

XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();
xmlJsonFormat.setEncoding("UTF-8");
xmlJsonFormat.setForceTopLevelObject(true);
xmlJsonFormat.setTrimSpaces(true);
xmlJsonFormat.setSkipNamespaces(true);
xmlJsonFormat.setRemoveNamespacePrefixes(true);
Pool a XML file from source directory and transform it to JSON format before sending it to destination directory
from("file:/inn?noop=true").marshal(xmlJsonFormat)
.setHeader(Exchange.FILE_NAME, simple("${file:onlyname.noext}.json"))
.to("file:/out").end();
It works great when i want a JSON string right from a XML without using a POJO.
But now consider a XML where I would like to omit an element.
Should I use another lib but camel-xmljson?
Is this way the right way of accomplish it:
JAXB lib to get a POJO from XML
Jackson lib to get a JSON from POJO and with excluding POJO fields from marshalling
I understand, even I would try to avoid any POJO's in camel routes.
Having said that, I wont just straight way let the XML out. I would put a XSLT after the xmljson component, so that I can trim the xml for desired output.
Thanks gnanagurus! This is quite simple using XSLT. Moreover the xslt: component is included in the last version of the core of Camel.
I defined an xlst file 'transform.xsl' taht includes the field that is to be omited. And then defined the Camel route like that:
from("file:/inn?noop=true")
.to("xslt:file:src/transform.xsl")
.marshal(xmlJsonFormat)
.setHeader(Exchange.FILE_NAME, simple("${file:onlyname.noext}.json"))
.to("file:/out").end();

custom snippet returning either JSON or XML

In my custom search options, I have specified a transform-results element.
<options xmlns="http://marklogic.com/appservices/search">
<transform-results apply="highlighted-person-summary-snippet" ns="http://ir.abbvie.com/people-db/person-query"
at="/ext/lib/person-query.xqy">
</transform-results>
</options>
Is there anyway that the XQuery function that implements the custom snippet can have access to what the accept headers are in the search request and be able to leverage that? I would rather not have two separate options XML files defined with the only difference being that one returns XML while the other one returns JSON.
Yes, just use xdmp:get-request-header. But if you emit a proper search:match element structure, the REST api should convert that automatically to json if necessary..
HTH!

Parsing phpdoc to JSON

I would like to find a way to use phpdoc2 to parse PHP projects into JSON rather than into Abstract Syntax Tree XML. Although of course I could just parse the XML into JSON, it seems that creating XML would be unnecessary overhead here.
So, in a nut shell, the question is: is there an easy way to configure phpdoc2's parser to directly produce JSON instead of XML? Or maybe some clues on what to extend in phpdoc2 to route the parsing output into JSON?
The story behind this question is: I would like to create JSDuck-like documentation for my PHP project. Although I have found that JSDuck can be used with PHP projects I won't go that way for the two reasons:
Don't want to part with phpdoc comments in my PHP classes or add something JSDuck-specific in there;
Don't really need the whole JSDuck doc interface as I am going to create a very custom one myself;
Prefer a PHP solution.
After half a day spent on phpdoc2 I finally found a solution which I believe is the right one. One should not worry or even know about Abstract Syntax Tree XML in phpdoc2 to achieve the goal.
The solution is:
Create a new writer class Json.php and place it in src/phpDocumentor/Plugin/Core/Transformer/Writer/ along with other writers. A good start point is to take the Graph.php writer and rewrite it to output JSON instead of SVG;
Create and use a new simple template like:
<?xml version="1.0" encoding="utf-8"?>
<template>
<transformations>
<transformation writer="Json" artifact="classes.json" />
</transformations>
</template>
Add Json writer to src/phpDocumentor/Plugin/Core/ServiceProvider.php's register method:
$writerCollection['Json'] = new Writer\Json();
And finally, just use the template when calling phpdoc on your project.