eerohele / exalt

A Sublime Text plugin for validating and formatting XML documents
MIT License
22 stars 3 forks source link

failed to located the main schema #21

Closed gamiller0 closed 5 years ago

gamiller0 commented 5 years ago

Hi,

Exalt has recently stopped validating against my schema. I haven't noticed exactly when it stopped, I am assuming it was with a version upgrade, but can't say when. Here is an example of my xsi:schemaLocation: xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/timeSeriesExportRun.xsd">

This used to work fine. If I remove the namespace (http://www.wldelft.nl/fews), it works fine. However, then the other tools I have like xmlspy show errors and complain about the missing namespace.

You have any ideas why this no longer works?

Thanks!

-Gabe

eerohele commented 5 years ago

Thanks for the report!

Yeah, this must be related to the latest update. I’ll try to take a look over the weekend.

gamiller0 commented 5 years ago

Great! Thanks for the quick response!

eerohele commented 5 years ago

Are you using an XML catalog with Exalt?

eerohele commented 5 years ago

I can reproduce the issue with this XML document:

EDIT: I can't immediately find a version of Exalt where validation worked without an XML catalog entry with this document, though. I'll keep digging later.

<?xml version='1.0' encoding='UTF-8'?>
<fews:timeSeriesExportRun xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fews="http://www.wldelft.nl/fews" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/timeSeriesExportRun.xsd">
  <fews:export>
    <fews:general>
      <fews:serializerClassName>nl.wldelft.timeseriesserializers.UDPTimeSeriesSerializer</fews:serializerClassName>
      <fews:serverUrl>http://udpserver:4445/path</fews:serverUrl>
      <fews:connectionTimeOutMillis>1000</fews:connectionTimeOutMillis>
      <fews:user>you</fews:user>
      <fews:password>secret</fews:password>
    </fews:general>
    <!--Optional:-->
    <fews:properties>
      <!--
-->
      <fews:string key="prefix" value="SMTVB"/>
      <!--

     Maximum size of package to be sent. If message is greater than this value then serializer will loop over message until all is sent.
     It is very important to know that if this value is greater than the max package size of the receiving service then messages will
     be truncated!

-->
      <fews:int key="packageSize" value="1024"/>
    </fews:properties>
    <!--Zero or more repetitions:-->
    <fews:timeSeriesSet>
      <fews:moduleInstanceId>string</fews:moduleInstanceId>
      <fews:valueType>scalar</fews:valueType>
      <fews:parameterId>not used</fews:parameterId>
      <!--
 The locationIds are used as character code in message. Character code must consist of three character values 
-->
      <fews:locationId>COD</fews:locationId>
      <!--
 <fews:locationSetId>locationSet</fews:locationSetId> 
-->
      <fews:timeSeriesType>external historical</fews:timeSeriesType>
      <fews:timeStep id="hour" multiplier="6"/>
      <!--
 For each timeseries only the last none missing value is added to the message 
-->
      <fews:relativeViewPeriod unit="hour" start="-1" end="0" startOverrulable="true" endOverrulable="false"/>
      <fews:readWriteMode>add originals</fews:readWriteMode>
    </fews:timeSeriesSet>
  </fews:export>
</fews:timeSeriesExportRun>
gamiller0 commented 5 years ago

sorry for the late reply. Here is an example xml file. Used to work fine. I am not using an xml catalogue only the online catalogue from the schema.

<?xml version="1.0" encoding="utf-8"?>
<generalAdapterRun xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/generalAdapterRun.xsd">
    <general>
        <description>xx</description>
        <rootDir>xxx</rootDir>
        <workDir>xx</workDir>
        <exportDir>xx</exportDir>
        <importDir>xx</importDir>
        <dumpFileDir>xx</dumpFileDir>
        <dumpDir>xx</dumpDir>
        <diagnosticFile>xx</diagnosticFile>
    </general>
    <activities>
        <executeActivities>
            <executeActivity>
                <command>
                    <executable>xx</executable>
                </command>
                <timeOut>90000</timeOut>
                <ignoreDiagnostics>true</ignoreDiagnostics>
            </executeActivity>
        </executeActivities>
    </activities>
</generalAdapterRun>
gamiller0 commented 5 years ago

Strange, the file I gave you did not appear to be giving me the same error. However it did not appear to be validating against the schema, only for properly formed xml. Here is another one that shows failed to locate the main schema resource.


<?xml version="1.0" encoding="UTF-8"?>
<forecastLengthEstimator xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/forecastLengthEstimator.xsd">
    <externalForecastTimeSeries>
        <moduleInstanceId>Send_Final_Flowsheet</moduleInstanceId>
        <valueType>scalar</valueType>
        <parameterId>QT</parameterId>
        <qualifierId>Sim</qualifierId>
        <locationSetId>HECRAS_Reservoirs</locationSetId>
        <timeSeriesType>external forecasting</timeSeriesType>
        <timeStep id="6HR_CST"/>
        <relativeViewPeriod unit="hour" start="-24" end="480"/>
        <readWriteMode>read only</readWriteMode>
    </externalForecastTimeSeries>
    <minForecastLength multiplier="1" unit="hour"/>
</forecastLengthEstimator>
eerohele commented 5 years ago

Thanks for the sample files. I was now able to reproduce the issue and I confirmed that it did work correctly in 0.3.6 (the previous version).

eerohele commented 5 years ago

It appears Exalt cannot locate the schema only if you're not using an XML catalog, which explains why the unit tests didn't catch the bug (I don't really want to be making network requests on every test run).

eerohele commented 5 years ago

I've just released v0.3.8, which should hopefully fix the issue. It should appear in Package Control after a while, so if you can, please give it a go and let me know whether the issue is resolved.

That said, I really recommend using an XML catalog, if possible. Without it, Exalt needs to fetch your schema over the network, which is slow and puts unnecessary burden on the servers hosting it.

I think entries similar to these but modified to use the namespace and URI for the schemas you're using should do the trick.

gamiller0 commented 5 years ago

Thanks for the quick fix! I will give it a try when I see it show up in Package control and let you know.

I'll consider using an XML catalog. The company updates their schema frequently, so that is why we usually try and do it over the network to assure we are using the latest.

gamiller0 commented 5 years ago

Works on v0.3.8. Thanks!!

eerohele commented 5 years ago

Good to hear it, thanks for letting me know!