[DFDL-WG] outputValueCalc to compute array elements - not possible?

Steve Hanson smh at uk.ibm.com
Wed Jun 5 05:40:48 EDT 2013


Mike

I think this would work if you used a fixed array. Then minOccurs = 
maxOccurs and you could use output defaulting rules to create the array.

Regards

Steve Hanson
Architect, IBM Data Format Description Language (DFDL)
Co-Chair, OGF DFDL Working Group
IBM SWG, Hursley, UK
smh at uk.ibm.com
tel:+44-1962-815848



From:   Mike Beckerle <mbeckerle.dfdl at gmail.com>
To:     dfdl-wg at ogf.org, 
Date:   04/06/2013 21:44
Subject:        [DFDL-WG] outputValueCalc to compute array elements - not 
possible?
Sent by:        dfdl-wg-bounces at ogf.org




I want to create an array of short strings from a single long string using 
outputValueCalc.

Let's call the initial single long string s. 

I want the max length of each short string to be m.

So ceiling(s/m) is the number of array elements.

Given m, it should be clear that each array element's contents can be 
computed as a specific sub-string of s, determined using m, and the index 
of the array element within the array, i.e., the position() function in 
XPath. The substring starts at m*(position() - 1), the end is length(s) - 
m*(position() -1) if position is ceiling(s/m), and start + m otherwise. 

However, current rules in the spec say that elements must exist in the 
infoset to be unparsed unless they are filled in by way of defaulting up 
to minOccurs. 

In my scenario I don't want to default them, I want to compute their 
values, but I do want to start with an infoset which has zero of the array 
elements pre-existing. I'm pretty sure there is no way for DFDL to will n 
array-elements into existence in the augmented infoset just knowing n, 
such that they then can each compute their sub-element's values using 
outputValueCalc.

Also I think we currently don't allow outputValueCalc on an array element 
anyway. But my array element could be a complex type containing an element 
with an outputValueCalc. 

So I think there is no way to achieve what I want, eventhough there's no 
issue with figuring out how many array elements there should be nor any 
issue with figuring out the contents of each array element.  

I raise this by way of wanting to be able to unparse somehow, anything I 
can parse. I can parse a variable-length array of strings, and compute a 
string which is their concatenation. It's tricky but doable. I cannot 
break up a long string into pieces which are in an array. 

-- 
Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology | 
www.tresys.com
--
  dfdl-wg mailing list
  dfdl-wg at ogf.org
  https://www.ogf.org/mailman/listinfo/dfdl-wg

Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ogf.org/pipermail/dfdl-wg/attachments/20130605/05b9c60e/attachment-0001.html>


More information about the dfdl-wg mailing list