DFDL's count function does not operate on any "node set", but on specific named array elements only.
In your case, the array is the row element, so { fn:count(/Document/row) + 1 } should give the value you want. On Wed, Dec 27, 2023 at 8:44 AM Roger L Costello <coste...@mitre.org> wrote: > Hi Folks, > > > > My input file has a field containing the number of “words” in the file, > where the “words” are the child elements of the root element. Here’s the > XML that parsing produces: > > > > <Document> > <initial_word> > <message_length>3</message_length> > </initial_word> > <row>...</row> > <row>...</row> > </Document> > > > > The message_length is the initial_word + number of <row> elements, i.e., 1 > + 2 = 3 > > > > I would like to hide message_length because it provides no meaningful > information in the XML (after all, if you want to know the message length > simply count the child elements of <Document>). > > > > To hide message_length, I will need a hidden group in my DFDL schema: > > > > <xs:group name="hidden-MESSAGE_LENGTH "> > <xs:sequence> > <xs:element name="hidden" type="unsignedint3" > dfdl:outputValueCalc="{????}"/> > </xs:sequence> > </xs:group> > > > > The challenge that I am having is what XPath to use in > dfdl:outputValueCalc. Initially, I used this: > > > > dfdl:outputValueCalc="{fn:count(/Document/*)} > > > > Daffodil complained: *Wildcard * is not supported.* > > > > Then I tried this: > > > > dfdl:outputValueCalc="{fn:count(../following-sibling::row)+1} > > > > Daffodil complained: *following-sibling axis is not supported.* > > > > Eek! > > > > I don’t know what else to try. Any suggestions? > > > > /Roger > > >