FW: [xquery-talk] optional attributes via function?

Dmitri.Colebatch at toyota.com.au Dmitri.Colebatch at toyota.com.au
Wed Sep 29 13:31:17 PDT 2004


Per,

having a little trouble with this....

> element widgetspecification {
>    attribute validFrom myfn:transformDate($spec/VALIDFROM),
>    myfn:outputValidToIfRequired($spec/VALIDTO),
>    ...
> }

using my input from the earlier email (repeated below) the following
'works':

  <widgetspecifications>
  {
    for $spec in $this//SPEC
    return
    <widgetspecification 
      validFrom="{$spec/VALIDFROM/text()}" 
      validTo="{$spec/VALIDTO/text()}">
    </widgetspecification>          
  }
  </widgetspecifications>

however, when I try to incorporate your suggested syntax change:

  <widgetspecifications>
  {
    for $spec in $this//SPEC
    return
      element widgetspecification {
        attribute validFrom $spec/VALIDFROM/text(),
        attribute validTo $spec/VALIDTO/text()
      }
  }
  </widgetspecifications>

I get an error.

I'm using BEA's engine which is based on the August 16, 2002 draft.  Does
the above rely on something in a newer version of the draft, or should it
work on that version?  Or - am I just missing something completely?

Am I right in thinking that the above is defined at
http://www.w3.org/TR/2002/WD-xquery-20020816/#id-sequencetype ?

thanks again,
dim

input document:

  <SPECS>
    <SPEC>
      <VALIDFROM>20020801</VALIDFROM>
      <VALIDTO>20020815</VALIDTO>
      <morestuff />
    </SPEC>
    <SPEC>
      <VALIDFROM>20020816</VALIDFROM>
      <VALIDTO>99991231</VALIDTO>
      <morestuff />
    </SPEC>
  </SPECS>

> 
> -- 
> 	--Per Bothner
> per at bothner.com   http://per.bothner.com/
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
> 

######################################################################
DISCLAIMER: 
This email and any attachment may contain confidential information.
If you are not the intended recipient you are not authorized to copy
or disclose all or any part of it without the prior written consent
of Toyota.

Opinions expressed in this email and any attachment are those of the
sender and not necessarily the opinions of Toyota.
Please scan this email and any attachment for viruses.
Toyota does not accept any responsibility for problems
caused by viruses, whether it is Toyota's fault or not.
######################################################################


More information about the talk mailing list