Author |
Message
|
smuktineni |
Posted: Fri Oct 24, 2014 2:02 pm Post subject: DFDL to XML attribute mapping |
|
|
 Apprentice
Joined: 28 Aug 2003 Posts: 33 Location: Omaha
|
We get fixed length input and then have to call a .net based SOAP web service which looks like every other SOAP Service except that most of the data input is in one element represented by all the attributes which are name value pairs of data structures defined in .net application that hosts the SOAP services. This attribute sets have to be sent as a CDATA in the element!
Ex request:
Code: |
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:nsp="http://www.tempuri.org">
<soapenv:Header/>
<soapenv:Body>
<nsp:Updatensp>
<nsp:strPlatform>Test</nsp:strPlatform>
<nsp:b64UserName>xxxxxxxxxxxxx</nsp:b64UserName>
<nsp:strGeographyXml><![CDATA[<geography geographyid="253625" city="My Home City" />]]> /nsp:strGeographyXml>
</nsp:Updatensp>
</soapenv:Body>
</soapenv:Envelope> |
The response is also in similar structure. We have a lot of attributes about 300 or more and am wondering what the right solution would be. I don't have an option on input, its a fixed length format and have been using DFDL and would prefer it as a solution if available as I would have to expose this as a internal web service myself down the road.
What is the best solution to map the DFDL to
<geography geographyid="253625" city="My Home City"
If I try to declare attributes like ...
Code: |
<xs:attribute dfdl:length="5" name="geographyid" type="xs:short" /> |
I get the error
CTDS1000E : Attribute declarations (local and global) are not allowed in DFDL schemas.
Thanks _________________ -Satish |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Oct 25, 2014 12:12 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Why not create the tree structure for the attributes in XMLNSC then use ASBITSTREAM and stuff it into the CData element...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kimbert |
Posted: Sat Oct 25, 2014 2:07 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Attribute declarations are not allowed in a DFDL 1.0 schema.
I suggest this approach:
- model the attributes as element declarations
- add a Compute node that sets the field type to XMLNSC.Attribute where that is required.
e.g.
Code: |
SET OutputRoot.XMLNSC = InputRoot.DFDL;
SET OutputRoot.XMLNSC.documentRoot.thisShouldBeAnAttribute TYPE = XMLNSC.Attribute;
SET OutputRoot.XMLNSC.documentRoot.andSoShouldThis TYPE = XMLNSC.Attribute;
... |
_________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
smuktineni |
Posted: Sat Oct 25, 2014 6:16 am Post subject: |
|
|
 Apprentice
Joined: 28 Aug 2003 Posts: 33 Location: Omaha
|
Thank you for the response. Yes I have already modeled the attributes as elements.
But your solution would mean manually mapping every field/attribute!
If manual mapping, we can directly map using DFDL source. Not sure what we will gain by transforming from DFDL to XML and then remapping to attributes.
Ex direct mapping if mapping each element (just typed, have to look up syntax for creating XML attributes)
SET OutputRoot.XMLNSC.documentRoot.thisShouldBeAnAttribute TYPE = InputRoot.DFDL.documentRoot.element;
Will using the .net node with data structures acquired from the .net hosting app help avoid manual mapping? _________________ -Satish |
|
Back to top |
|
 |
kimbert |
Posted: Mon Oct 27, 2014 4:57 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Actually, looking at this again I would like to modify my advice to:
- model the attributes as element declarations
- add a Compute node that sets the field type to XMLNSC.Attribute on every child of OutputRoot.XMLNSC.geography
- use ASBITSTREAM to create a BLOB containing the <geography ...> tag, CAST to CHARACTER and assign the resulting string to an output tag containing a CDATA section.
XMLNSC attributes and CDATA are described clearly in the knowledge center so I will leave the implementation as an exercise for the reader. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
|