Hi Mike,


But, but, but, ...



I am trying to illustrate the use of truncateSpecifiedLengthString.



Look at what the spec says for truncateSpecifiedLengthString:



Used on unparsing only.

'yes' means if the logical type is xs:string and the value (the parsed value?) 
is longer than the specified length (what specified length?), the string is 
truncated to this length (truncated on unparsing, right?).



I interpreted that to mean the value resulting from parsing 
(Wolfeschlegelsteinhausenbergerdorff) could be truncated on unparsing. I read 
the spec and wondered, "Okay, on unparsing I can specify that I want the value 
truncated, but how do I specify the length at which truncation begins?"



/Roger



From: Beckerle, Mike <mbecke...@tresys.com>

Sent: Tuesday, May 26, 2020 12:49 PM

To: users@daffodil.apache.org

Subject: [EXT] Re: How to use truncateSpecifiedLengthString?



Typo . Should be "fn:substring(../personName, 1, 15)"



________________________________________

From: Beckerle, Mike <mailto:mbecke...@tresys.com>

Sent: Tuesday, May 26, 2020 12:47 PM

To: mailto:users@daffodil.apache.org <mailto:users@daffodil.apache.org>

Subject: Re: How to use truncateSpecifiedLengthString?



Interesting requirement. So you want it to accept when parsing any length but 
unparsing is not symmetric with that, it wants to truncate.



Presumably this is delimited on parsing, so that it can accept all the 
characters at parse time.



Hmmm. I think this is going to require you to use inputValueCalc and 
outputValueCalc. Something like this:



<element name="storedName" type="xs:string"

    dfdl:outputValueCalc='{ fn:substring(../name, 1, 15) }' ... plus other 
properties .... />

<element name="personName" type="xs:string"

    dfdl:inputValueCalc='{ ../storedName }' />











________________________________________

From: Roger L Costello <mailto:coste...@mitre.org>

Sent: Tuesday, May 26, 2020 12:40 PM

To: mailto:users@daffodil.apache.org <mailto:users@daffodil.apache.org>

Subject: How to use truncateSpecifiedLengthString?



Hi Folks,



My input contains this person's last name:



Wolfeschlegelsteinhausenbergerdorff



I want parsing to generate:



<personName>Wolfeschlegelsteinhausenbergerdorff</personName>



I want unparsing to truncate the name after 15 characters. It would seem that I 
should use truncateSpecifiedLengthString="yes" to indicate that the name should 
be truncated. But how to specify that the name should be truncated after 15 
characters? I cannot use length="15" because that would cause parsing to fail.



/Roger


Reply via email to