You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by Roger L Costello <co...@mitre.org> on 2020/05/26 16:40:31 UTC

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



Re: How to use truncateSpecifiedLengthString?

Posted by "Beckerle, Mike" <mb...@tresys.com>.
Typo . Should be "fn:substring(../personName, 1, 15)"

________________________________
From: Beckerle, Mike <mb...@tresys.com>
Sent: Tuesday, May 26, 2020 12:47 PM
To: users@daffodil.apache.org <us...@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 <co...@mitre.org>
Sent: Tuesday, May 26, 2020 12:40 PM
To: users@daffodil.apache.org <us...@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



Re: How to use truncateSpecifiedLengthString?

Posted by "Beckerle, Mike" <mb...@tresys.com>.
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 <co...@mitre.org>
Sent: Tuesday, May 26, 2020 12:40 PM
To: users@daffodil.apache.org <us...@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