Skip to content

Using XInclude #112

@benjwadams

Description

@benjwadams

Hi, I attempted to use XInclude to reduce the amount of repetitive boilerplate XML for very similar datasets in datasets.xml.

In the document root, I added an XML namespace for XInclude: <erddapDatasets xlmns:xi="http://www.w3.org/2001/XInclude">

Later on, in between the </addAttributes> and </dataset> closing tag, I attempted to run the XInclude snippet:

<xi:include href="hfradar_dataset_variables.xml"/>

Attempting to reload the datasets results in no datasets properly loading, and this being reported in log.txt:

ERROR while processing line #164 datasets.xml: java.lang.RuntimeException: datasets.xml error on line #164: java.lang.RuntimeException: datasets.xml error on or before line #164: ERROR in XML file on line #164: Unexpected tag=<erddapDatasets><dataset><xi:include> content="".
 at gov.noaa.pfel.erddap.LoadDatasets.run(LoadDatasets.java:460)
Caused by: java.lang.RuntimeException: datasets.xml error on or before line #164: ERROR in XML file on line #164: Unexpected tag=<erddapDatasets><dataset><xi:include> content="".
 at gov.noaa.pfel.erddap.dataset.EDD.fromXml(EDD.java:486)
 at gov.noaa.pfel.erddap.LoadDatasets.run(LoadDatasets.java:364)
Caused by: java.lang.Exception: ERROR in XML file on line #164: Unexpected tag=<erddapDatasets><dataset><xi:include> content="".
 at gov.noaa.pfel.coastwatch.util.SimpleXMLReader.throwException(SimpleXMLReader.java:600)
 at gov.noaa.pfel.coastwatch.util.SimpleXMLReader.unexpectedTagException(SimpleXMLReader.java:589)
 at gov.noaa.pfel.erddap.dataset.EDDTableFromFiles.fromXml(EDDTableFromFiles.java:347)
 at gov.noaa.pfel.erddap.dataset.EDD.fromXml(EDD.java:463)
 ... 1 more

I don't use XML a ton, but it looks to me that this should be valid XML. Please let me know if I'm doing something wrong that could be easily fixed. I have looked at source and it looks like ERDDAP's XML parser deviates from many other mainstream XML parsers. Can it support XInclude snippets like the above to reduce the amount of repeated boilerplate variables?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions