Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pds4_create_xml_index: Ugly error message when label does not parse properly #39

Open
rfrenchseti opened this issue Sep 24, 2024 · 0 comments

Comments

@rfrenchseti
Copy link
Collaborator

If a label file does not parse properly, the error message is not useful, both because it gives a Python traceback and because it doesn't tell you the name of the file that has the problem. Parsing failure can be like the example below, or can be just a normal syntax error (like a missing <).

For example:

❯ pds4_create_xml_index . rf_tester_label_1.xml 
Traceback (most recent call last):
  File "/seti/all_repos/rms-pds4indextools/venv/bin/pds4_create_xml_index", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/seti/all_repos/rms-pds4indextools/pds4indextools/pds4_create_xml_index.py", line 1322, in main
    tree = etree.parse(str(label_file))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/lxml/etree.pyx", line 3589, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1958, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1984, in lxml.etree._parseDocumentFromURL
  File "src/lxml/parser.pxi", line 1887, in lxml.etree._parseDocFromFile
  File "src/lxml/parser.pxi", line 1200, in lxml.etree._BaseParser._parseDocFromFile
  File "src/lxml/parser.pxi", line 633, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 743, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 672, in lxml.etree._raiseParseError
  File "rf_tester_label_1.xml", line 22
lxml.etree.XMLSyntaxError: Namespace prefix geom on Geometry is not defined, line 22, column 27

with rf_tester_label_1.xml as:

<?xml version="1.0" encoding="UTF-8"?>
<Product_Observational
  xmlns="http://pds.nasa.gov/pds4/pds/v1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
  http://pds.nasa.gov/pds4/pds/v1 https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1B00.xsd
  http://pds.nasa.gov/pds4/disp/v1 https://pds.nasa.gov/pds4/disp/v1/PDS4_DISP_1B00.xsd
  http://pds.nasa.gov/pds4/mission/cassini/v1 https://pds.nasa.gov/pds4/mission/cassini/v1/PDS4_CASSINI_1B00_1300.xsd">
    <Identification_Area>
        <logical_identifier>urn:nasa:pds:cassini_iss_saturn:data_raw:1455200455n</logical_identifier>
        <version_id>1.0</version_id>
        <title>Cassini ISS Image 1455200455n.img</title>
        <information_model_version>1.11.0.0</information_model_version>
        <Citation_Information>
            <author_list>French, Richard G.</author_list>
            <publication_year nilReason="unknown" xsi:nil="true"/>
            <keyword>kw1</keyword>
        </Citation_Information>
    </Identification_Area>
    <Observation_Area>
        <Discipline_Area>
            <geom:Geometry>
                <geom:SPICE_Kernel_Files>
                    <geom:SPICE_Kernel_Identification>
                        <geom:kernel_type>SPK</geom:kernel_type>
                        <geom:spice_kernel_file_name>ura111.bsp</geom:spice_kernel_file_name>
                    </geom:SPICE_Kernel_Identification>
                    <geom:comment>These kernel files were used in the generation of the products in the parent bundle. Some or all of them may not have been used directly in the generation of this product.</geom:comment>
                </geom:SPICE_Kernel_Files>
            </geom:Geometry>
        </Discipline_Area>
    </Observation_Area>
    <Observing_System>
        <name>Cassini Orbiter Imaging Science Subsystem</name>
        <Observing_System_Component>
            <name>Cassini Orbiter</name>
            <type>Spacecraft</type>
            <Internal_Reference>
                <lid_reference>urn:nasa:pds:context:instrument_host:spacecraft.co</lid_reference>
                <reference_type>is_instrument_host</reference_type>
            </Internal_Reference>
        </Observing_System_Component>
    </Observing_System>
</Product_Observational>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants