I want to write an XML in below format:
<Parent>
<TotalEmployees>2</TotalEmployees>
<CompanyName>ABCD</CompanyName>
<Employee>
<Name>YYYYY</Name>
<Details>
<EmployeeId>12345</EmployeeId>
<Job>Permanent</Job>
</Details>
</Employee>
<Employee>
<Name>XXXXX</Name>
<Details>
<EmployeeId>67892</EmployeeId>
<Job>Contract</Job>
</Details>
</Employee>
</Parent>
The Employee fragement would repeat and the total number of employee statistics is provided in the TotalCount (calculated value).
Is this possible with StaxItemWriter or should I go for custom ItemWriter. I tried to use headercallback but it did not help. Please guide me.
Related
I have an XML as a NodeSeq. I am looking for an option to traverse the tags inside the xml and assign a sequence number to each tag.
For example, consider the below XML is available as a Node Seq. I need to add an attribute SeqNum and assign a sequence number value for each of the tags in a List of tags {Employee, name, age}.
<Employees>
<Employee>
<name>Name1</name>
<age>30</age>
<Remarks>xxxx</Remarks>
</Employee>
<Employee>
<name>Name1</name>
<age>30</age>
<Remarks>xxxx</Remarks>
</Employee>
</Employees>
The output xml should be as below:
<Employees>
<Employee SeqNum="001001">
<name SeqNum="001002">Name1</name>
<age SeqNum="001003">30</age>
<Remarks>xxxx</Remarks>
</Employee>
<Employee SeqNum="002001">
<name SeqNum="002002">Name1</name>
<age SeqNum="002003">30</age>
<Remarks>xxxx</Remarks>
</Employee>
</Employees>
Please share your suggestion to achieve this in scala.
I'm looking for file which is responsible for model of completed data in xml. For example it looks like:
<form xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:saxon="http://saxon.sf.net/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:version="java:org.orbeon.oxf.common.Version" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:exf="http://www.exforms.org/exf/1-0">
<section-1>
<control-3>name</control-3>
<control-1>second-name</control-1>
</section-1>
</form>
This example could store simple form which contains two input field (name, second-name).
I want to find it, because I want to add parameter contains id of user who complete this form. So I want to change model, to reach following effect in completed form xml:
<form xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:saxon="http://saxon.sf.net/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fb="http://orbeon.org/oxf/xml/form-builder" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:version="java:org.orbeon.oxf.common.Version" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:exf="http://www.exforms.org/exf/1-0">
<user-who-complete-this-form-ID>100</user-who-complete-this-form-ID>
<section-1>
<control-3>name</control-3>
<control-1>second-name</control-1>
</section-1>
</form>
Or maybe someone knows other way to provide id of user who complete form to own persistence layer?
regards
This looks like the data for a form you created in Form Builder. If that is indeed the case, and you want to add a field, you can do it from Form Builder, republish the form, and the instances of the new form will have the additional field you added.
I need to parse a XML file from the website.I have went through some links like ray wenderlich,etc.,But first i need to know how the XML parsing is working. So i have decided to parse a simple xml file which is given below.
<?xml version="1.0" encoding="UTF-8"?>
<employees>
<emp id = "100" name = "Cyril">
<details>
<desc>This Employee is working in this company for the past 5 years
</desc>
<age>35</age>
</details>
</emp>
<emp id = "101" name = "Ram">
<details>
<desc>This Employee is working in this company for the past 3 years
</desc>
<age>28</age>
</details>
</emp>
</employees>
Can anyone help me ?
you can use NSXMLParser for the same and you need to implement its delegates where you will receive the parsed values.
I am working with wmqfte. While creating a transfer there is a parameter for metadata attribute pair. Why is this used for ?
One of the FTE engagements I worked on required email notifications of transfer status. Our approach to this was to add an email step in the transfer and the way we passed in the source and destination addresses was with metadata pairs. The transfer XML is provided below for an example:
<?xml version="1.0" encoding="UTF-8"?><request version="4.00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FileTransfer.xsd">
<!DOCTYPE request>
<managedTransfer>
<originator>
<hostName>host.example.com</hostName>
<userID>me</userID>
</originator>
<sourceAgent QMgr="QMGR01" agent="AGENT01"/>
<destinationAgent QMgr="QMGR02" agent="AGENT02"/>
<transferSet priority="5">
<metaDataSet>
<metaData key="email.from">fteadmin#example.com</metaData>
<metaData key="email.to">"dept#example.com</metaData>
</metaDataSet>
<item checksumMethod="MD5" mode="binary">
<source disposition="delete" recursive="false">
<file>/root/path/file</file>
</source>
<destination exist="overwrite" type="directory">
<file>/root/path/</file>
</destination>
</item>
</transferSet>
<job>
<name>Your Job Name Here</name>
</job>
</managedTransfer>
</request>
A better way of sending status emails is to watch the transfer notifications published at the Coordination QMgr. However this example does show one possible use for the metadata pairs.
Let's say I have a class called Store that has many Employees. My RESTful listXML method looks like this:
def listXML = {
render Store.list() as XML
}
And the result looks like this:
<stores>
<store id="1">
<name>My Store</name>
<employees>
<employee id="1" />
</employees>
</store>
</store>
My question is, how do I include all the data of each Employee class, so that my XML looks something like this?
<stores>
<store id="1">
<name>My Store</name>
<employees>
<employee id="1">
<name>John Smith</name>
<hireDate>2008-01-01</hireDate>
</employee>
</employees>
</store>
</store>
In your controller, you'll want to import the deep converter:
import grails.converters.deep.XML
You can read about it in the first couple of paragraphs of the Converters Reference.
As of Grails 1.1 you will be able to configure Grails to default to deeply serializing by including this in your grails-app/conf/Config.groovy:
grails.converters.xml.default.deep = true
1.1 also introduces named configurations for Converters. The deep converters will be deprecated and the named configuration "deep" should be used instead.
XML.use("deep") {
render model as XML
}