Hi,

When serializing XML to CSV, special characters (e.g., &) are not converted to their textual representations (e.g., ‘&’).

For example, the code below outputs

conditionid nctid condition
1 NCT00130377 Cardiovascular System Diseases (& [Cardiac])

vs. the expected

conditionid nctid condition
1 NCT00130377 Cardiovascular System Diseases (& [Cardiac])

This seems like a bug. Am I missing an option? I did not see anything related in the documentation.

Thanks,
Ron


let $options := map { 'lax': false(), 'quotes' : false(), 'separator' : 'tab', 'header' : true() }

return file:write('conditions.tsv',
  csv:serialize(
    <matches> {
      for $article in db:open('CTGov')/clinical_study
      where $article//nct_id = 'NCT00130377'
      for $condition in $article/condition
      count $c
      return
        <match>
          <conditionid> { $c } </conditionid>,
          <nctid> { normalize-space($article/id_info/nct_id/text()) } </nctid>,
          <condition> { normalize-space($condition/text()) } </condition>
        </match> }
    </matches>,
    $options)
  )