cds-astro / cds-votable-rust

Library to read/write VOTables in Rust and to convert them in JSON, YAML, TOML and back to XML.
Apache License 2.0
5 stars 1 forks source link

Unexpected INFO event. Expected: End. Actual: CData(BytesCData... #7

Closed bmatthieu3 closed 1 year ago

bmatthieu3 commented 1 year ago

The votable returned by the cdsxmatch service is not parsed correctly: http://cdsxmatch.u-strasbg.fr/QueryCat/QueryCat?catName=SIMBAD&mode=cone&pos=M1&r=50arcmin&format=votable&limit=3000

It has the following error message:

caught Error parsing votable: Custom("Unexpected INFO event. Expected: End. Actual: CData(BytesCData { content: Borrowed(\"0xA(${otype}=\\"Star\\" || ${otype}=\\"\*\\") && (${B}!=0 || ${V}!=0 || ${R}!=0 || ${J}!=0 || ${K}!=0) {0xA draw pm(${pmra},${pmdec})0xA draw circle(-$[phot.mag],3,15)0xA}0xA(${otype}=\\"Star\\" ||${otype}=\\"\*\\") && ${B}=\\"\\" && ${V}=\\"\\" && ${R}=\\"\\" && ${J}=\\"\\" && ${K}=\\"\\" {0xA draw pm(${pmra},${pmdec})0xA draw circle(3)0xA}0xA${otype}=\\"Radio\\" || ${otype}=\\"Maser\\" || ${otype}=\\"HI\\" { draw triangle }0xA${otype}=\\"UV\\" {draw cross;draw plus}0xA${otype}=\\"IR\\" || ${otype}=\\"Red\\" {draw rhomb}0xA${otype}=\\"Neb\\" || ${otype}=\\"PN\\" || ${otype}=\\"SNR*\\" {draw square}0xA${otype}=\\"HII\\" { draw dot }${otype}=\\"X\\" { draw cross }0xA${otype}!=\\"Unknown\\" { draw ${otype} }0xA{ draw dot }\") }).") p

Maybe it is the INFO content starting with a '<!' that triggers the error:

<VOTABLE version="1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ivoa.net/xml/VOTable/v1.1 http://www.ivoa.net/xml/VOTable/v1.1"
xmlns="http://www.ivoa.net/xml/VOTable/v1.1">
    <DESCRIPTION>
        Generated by the Java software cds.catfile.v1.
        Please report any problem to: cds-question@unistra.fr
    </DESCRIPTION>
    <DEFINITIONS>
        <COOSYS ID="COOSYS" system="ICRS" equinox="2000.0" epoch="2000.0"/>
    </DEFINITIONS>
    <RESOURCE name="CDSCatfFile query service, CDS">
        <INFO ID="SimbadHFilter" name="AladinFilter" value="All objects">
<![CDATA[
(${otype}="Star" || ${otype}="*\**") && (${B}!=0 || ${V}!=0 || ${R}!=0 || ${J}!=0 || ${K}!=0) {
   draw pm(${pmra},${pmdec})
   draw circle(-$[phot.mag*],3,15)
}
(${otype}="Star" ||${otype}="*\**") && ${B}="" && ${V}="" && ${R}="" && ${J}="" && ${K}="" {
   draw pm(${pmra},${pmdec})
   draw circle(3)
}
${otype}="Radio*" || ${otype}="Maser" || ${otype}="HI" { draw triangle }
${otype}="UV" {draw cross;draw plus}
${otype}="IR" || ${otype}="Red*" {draw rhomb}
${otype}="Neb"  || ${otype}="PN*" || ${otype}="SNR*" {draw square}
${otype}="HII" { draw dot }${otype}="X" { draw cross }
${otype}!="Unknown" { draw ${otype} }
{ draw dot }]]>
        </INFO>
fxpineau commented 1 year ago

The problem comes from CDATA that is no supported so far. I may simply ignore CDATA and its content in a first step...

fxpineau commented 1 year ago

Now CDATA is accepted in 'Info', 'Desciption', 'Link', 'ParamRef' and 'FieldRef' content, see v0.2.3