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.
As of now according to the information mentioned in the citrus documentation we can send header using element tag .I have a header like this
<usr><scenarioname>xx</scenarionname><instanceID>xx<<instanceID><usr>
I am sending the above header using follwing send action
<send endpoint="helloServiceEndpoint">
<message>
<payload>
<TestMessage>
<Text>Hello!</Text>
</TestMessage>
</payload>
</message>
<header>
<element name="scenarioname" value="xx"/>
<element name="instanceID" value="xx"/>
</header>
</receive>
But I want to post a complex header which not just like name value pairs but the header contains nested xml elements. how can i achieve this using citrus
example of complex header
<usr>
<scenarioname>xx</scenarionname>
<instanceID>xx<<instanceID>
<parameters>
<basicauthentication>
<username>xxxxx</username>
<password>xxxx</password>
</basicauthentication>
.
.
.
.
.
</parameters>
</usr>
The element is for name-value pairs only. You need to use the data element in the header section in order to add a complex header fragment.
<send endpoint="helloServiceEndpoint">
<message>
<payload>
<TestMessage>
<Text>Hello!</Text>
</TestMessage>
</payload>
</message>
<header>
<data>
<![CDATA[
<usr>
<scenarioname>xx</scenarionname>
<instanceID>xx</instanceID>
</usr>
]]>
</data>
</header>
</send>
I have an issue with build-in (non accessible) webMethods Integration Server soapClient service. Somehow it changes the request it should send while processing it, renaming parameter items to item.
what is send to the method:
<request>
<t1>1</t1>
<operation>op</operation>
<service>1</service>
<params>
<count>1</count>
<items>
<key>12</key>
<value>12</value>
</items>
</params>
</request>
what request webmethods sends:
<request>
<t1>1</t1>
<operation>op</operation>
<service>1</service>
<params>
<count>1</count>
<item>
<key>12</key>
<value>12</value>
</item>
</params>
</request>
I'd be grateful for any workaround/idea for a solution.
I see in your example code that you first create an document named "items", then you map this document to a document list named "items". This is not valid. Please note that the pipeline in IntegrationServer is nothing but a key-value map, and the keys must be unique. That is the reason why you still have a single document named "items" instead of a document list. Rename your document to something like "item", and then use appendToDocumentList to add it to the "items" doc list.
I have 2 tables, DATA and IMAGES, in a relationship based on item_number.
Records in DATA each have 3 records from IMAGES gathered.
For example, a record with item_number 010050 is linked to these records in IMAGES:
010050.eps
010050_table.tif
010050_drawing.png
In the corresponding record in DATA I have the fields:
main
table
drawing
My aim is to set the fields in DATA like:
010050.eps => main
010050_table.tif => table
010050_drawing.png => drawing
I tried:
ExecuteSQL("SELECT filename FROM images WHERE filename = ?"; ""; ""; "010050_drawing")
Who could give me a hint?
I couldn't figure out how I can do that in xslt.
To take a simplified example, suppose you have exported from your Data table, with only two fields included in the export: Data::ItemNumber and Images::FileName. Your raw export would then look something like this (two records shown):
XML
<?xml version="1.0" encoding="UTF-8"?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="" NAME="FileMaker" VERSION=""/>
<DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/>
<METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="ItemNumber" TYPE="NUMBER"/>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Images::FileName" TYPE="NUMBER"/>
</METADATA>
<RESULTSET FOUND="2">
<ROW MODID="0" RECORDID="1">
<COL>
<DATA>010050</DATA>
</COL>
<COL>
<DATA>010050.eps</DATA>
<DATA>010050_table.tif</DATA>
<DATA>010050_drawing.png</DATA>
</COL>
</ROW>
<ROW MODID="0" RECORDID="2">
<COL>
<DATA>2345</DATA>
</COL>
<COL>
<DATA>2345_extra.gif</DATA>
<DATA>2345_table.gif</DATA>
<DATA>2345_drawing.jpg</DATA>
<DATA>2345.tiff</DATA>
</COL>
</ROW>
</RESULTSET>
</FMPXMLRESULT>
Note the different order as well as the extra image in the second record.
After applying the following stylesheet:
XSLT
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fmp="http://www.filemaker.com/fmpxmlresult"
exclude-result-prefixes="fmp">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<root>
<xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW">
<xsl:variable name="item-no" select="fmp:COL[1]/fmp:DATA"/>
<item>
<number>
<xsl:value-of select="$item-no"/>
</number>
<main>
<xsl:value-of select="fmp:COL[2]/fmp:DATA[starts-with(., concat($item-no, '.'))]"/>
</main>
<table>
<xsl:value-of select="fmp:COL[2]/fmp:DATA[starts-with(., concat($item-no, '_table.'))]"/>
</table>
<drawing>
<xsl:value-of select="fmp:COL[2]/fmp:DATA[starts-with(., concat($item-no, '_drawing.'))]"/>
</drawing>
</item>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
you would obtain:
Result
<?xml version="1.0" encoding="UTF-8"?>
<root>
<item>
<number>010050</number>
<main>010050.eps</main>
<table>010050_table.tif</table>
<drawing>010050_drawing.png</drawing>
</item>
<item>
<number>2345</number>
<main>2345.tiff</main>
<table>2345_table.gif</table>
<drawing>2345_drawing.jpg</drawing>
</item>
</root>
Honestly, unless there's more happening than what you've described, you're making this too hard.
If there will always be exactly 3 IMAGE records for each DATA record, and especially if you want to directly relate each image to a specific type, you don't need the IMAGE table. A much simpler solution would be to add 3 container fields to your DATA table (say, main_image, table_image, drawing_image). You wouldn't need SQL or a portal, and you wouldn't have to worry about keeping related images linked to their type.
OTOH, if you truly need a separate table, consider hard-wiring three dedicated 1:1 relationships, one for each image type. To do this, add 3 special key fields in DATA: (main_image_id, etc.) and create a relationship for each image type, each between one of these fields and the primary IMAGE. Then, whenever you create a DATA record and 3 related IMAGE records, put the key of the matching image in the matching DATA::xxx_image_id field. That way, you'd have a clean 1:1 relationship, and each related image would be locked to its type.
thanks for your replies
I need the value of the images in those fields to get it exported to XML and InDesign (into table cells).
The issue is that I know the filenames , namely the item_number followed by _drawing or _table, but don't know the extension on forehand (many files and from different sources)
File formats differ therefore.
My solution now is:
- imported all the images in a related (item_number, his is also part of the filename) a FMP table
- I calculated whether the file is a table, drawing or illustration and put those values in a field 'kind' by:
Case (
PatternCount ( filename ; "_drawing." ) ;
"drawing" ;
PatternCount ( filename ; "_table." ) ;
"table" ;
Length ( filename )=10 ;
"main" ;
""
)
- then I did the query in each of the fields, main - table - drawing. The one below is the calculation in the 'table' field.
ExecuteSQL("
SELECT path_xml
FROM images
WHERE item_number = ? and kind = ?";
"";""; item_number ; "table"); ""
)
Perhaps a bit clumsy, but it works now.
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
}