Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't find XSD to validate XML 1

Status
Not open for further replies.

goBoating

Programmer
Feb 8, 2000
1,606
US
Total newb question. I've played with XML a few times over the years.

Now I need to validate an XML doc against an XSD. I've tried using NetBeans, XMLSpy, Visual Studio, and a Perl script and all are failing to find/parse the XSD as it is identified in the XML doc. The top of the XML doc looks like:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<om:CompositeObservation 
	xmlns:om="[URL unfurl="true"]http://www.opengis.net/om/1.0"[/URL] 
	xmlns:xlink="[URL unfurl="true"]http://www.w3.org/1999/xlink"[/URL] 
	xmlns:gml="[URL unfurl="true"]http://www.opengis.net/gml/3.2"[/URL] 
	xmlns:swe="[URL unfurl="true"]http://www.opengis.net/swe/1.0.2"[/URL] 
	xmlns:ioos="[URL unfurl="true"]http://www.noaa.gov/ioos/0.6.1"[/URL] 
	xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] 
	gml:id="CurrentsVerticalProfileCollectionTimeSeriesObservation" 
	[b]xsi:schemaLocation="[URL unfurl="true"]http://www.csc.noaa.gov/ioos/schema/IOOS-DIF/IOOS/0.6.1/schemas/ioosObservationSpecializations.xsd[/URL][/b]">
  <!--==============================================-->
  <!-- Information generated on 2008-10-23T13:53:04Z-->
  <!-- by these experimental services are valid at  -->
  <!-- this time only.                              -->
  <!--==============================================-->
  <gml:description>Currents observation at a collection of profiles at a series of times</gml:description>
  <gml:name>NOAA.NOS.CO-OPS observations at station ID cb0402</gml:name>
... xml doc truncated for brevity ...

The XSD file is well formed and is where the xsi:schemaLocation attributes says it should be.

None of the validation engines in any of the software packages I'm trying to use is finding the xsd file.

It appears to me that the xsi:schemaLocation content is mal-formed. Shouldn't there be two items in that content instead of the one fully qualified path to the xsd file?

Code:
xsi:schemaLocation="namespace/uri/of/some/sort   filename.xsd"

Thanks,

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
>Shouldn't there be two items in that content instead of the one fully qualified path to the xsd file?
That's correct. In this case, it should be written like this.
[tt]
xsi:schemaLocation="[blue][ignore][/ignore][/blue][ignore] [/ignore]"
[/tt]
In any case, that piece of information is just suggestive and can be overriden by the processor if so directed.
 
Thanks, tsuji.

The xml doc now validates against the internally referenced schema identified by the xsi:schemaLocation using XMLSpy. However, I've tried to use several other applications to validate the doc and none of the others will do it. I ran into this variability a while back when trying to do the same trick (different project). We were never able to put together an xsi:schemaLocation that would work in most tools/applications. We could get our XML to validate using some packages but we never got to the point that we had a good approach that would work in most.

Have you had any experience/luck with that?

I've tried XMLSpy (works), Visual Studio (doesn't), NetBeans (doesn't), a small piece of Java (doesn't), and simple little Perl script (works).





'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Failure to deliver is not a generalized phenomenon on validation. If you have problems of getting it through, you could surely ask here or the corresponding specialized forums. Validation usually involves many inputs and setting details and cannot be treated lightly.
 
Got it to work in NetBeans and XMLSpy, although XMLSpy is a little more forgiving with the xsi:schemaLocation attribute.

The following XML validates in both tools.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<om:CompositeObservation 
xmlns:om="[URL unfurl="true"]http://www.opengis.net/om/1.0"[/URL] 
xmlns:xlink="[URL unfurl="true"]http://www.w3.org/1999/xlink"[/URL] 
xmlns:gml="[URL unfurl="true"]http://www.opengis.net/gml/3.2"[/URL] 
xmlns:swe="[URL unfurl="true"]http://www.opengis.net/swe/1.0.2"[/URL] 
xmlns:ioos="[URL unfurl="true"]http://www.noaa.gov/ioos/0.6.1"[/URL] 
xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] 
gml:id="CurrentsVerticalProfileCollectionTimeSeriesObservation" 
xsi:schemaLocation="[URL unfurl="true"]http://www.opengis.net/om/1.0[/URL] [URL unfurl="true"]http://www.csc.noaa.gov/ioos/schema/IOOS-DIF/IOOS/0.6.1/schemas/ioosObservationSpecializations.xsd">[/URL]
  <!--==============================================-->
  <!-- Information generated on 2008-10-23T13:53:04Z-->
  <!-- by these experimental services are valid at  -->
  <!-- this time only.                              -->
  <!--==============================================-->
  <gml:description>Currents observation at a collection of profiles at a series of times</gml:description>
  <gml:name>NOAA.NOS.CO-OPS observations at station ID cb0402</gml:name>
  <gml:boundedBy>
    <gml:Envelope srsName="urn:ogc:def:crs:epsg::4326">
      <gml:lowerCorner>36.9627 -76.3338</gml:lowerCorner>
      <gml:upperCorner>36.9627 -76.3338</gml:upperCorner>
    </gml:Envelope>
  </gml:boundedBy>
  <om:samplingTime>
    <gml:TimePeriod gml:id="ST">
      <gml:beginPosition>2008-04-01T12:05:00Z</gml:beginPosition>
      <gml:endPosition>2008-04-01T12:05:00Z</gml:endPosition>
    </gml:TimePeriod>
  </om:samplingTime>
  <om:procedure>
    <om:Process>
      <ioos:CompositeContext gml:id="SensorMetadata" recDef="[URL unfurl="true"]http://www.csc.noaa.gov/ioos/schema/IOOS-DIF/IOOS/0.6.1/recordDefinitions/PointSensorMetadataRecordDefinition.xml">[/URL]
        <gml:valueComponents>
          <ioos:Count name="NumberOfStations">1</ioos:Count>
          <ioos:ContextArray gml:id="StationArray">
            <gml:valueComponents>
              <ioos:CompositeContext gml:id="Station1Info">
                <gml:description>These raw data have not been subjected to the National Ocean Service's quality control or quality assurance procedures and do not meet the criteria and standards of official National Ocean Service data. They are released for limited public use as preliminary data to be used only with appropriate caution.</gml:description>
                <gml:valueComponents>
                  <ioos:StationName>Naval Station Norfolk LB 7 (ATON)</ioos:StationName>
                  <ioos:Organization>NOAA.NOS.CO-OPS</ioos:Organization>
                  <ioos:StationId>urn:x-noaa:def:station:NOAA.NOS.CO-OPS:cb0402</ioos:StationId>
                  <gml:Point gml:id="Station1LatLon">
                    <gml:pos>36.9627 -76.3338</gml:pos>
                  </gml:Point>
                  <ioos:VerticalDatum>urn:ogc:def:datum:epsg::5113</ioos:VerticalDatum>
                  <ioos:VerticalPosition>0.0</ioos:VerticalPosition>
                  <ioos:Context name="TotalWaterDepth" uom="m">16.46</ioos:Context>
                  <ioos:Count name="Station1NumberOfSensors">1</ioos:Count>
                  <ioos:ContextArray gml:id="Station1SensorArray">
                    <gml:valueComponents>
                      <ioos:CompositeContext gml:id="Station1Sensor1Info">
                        <gml:valueComponents>
                          <ioos:SensorId>urn:x-noaa:def:sensor:NOAA.NOS.CO-OPS:cb0402:Nortek-ADP-496</ioos:SensorId>
                          <ioos:Text name="Orientation">downwardLooking</ioos:Text>
                          <ioos:Context name="SensorDepth" uom="m">3.06</ioos:Context>
                          <ioos:SamplingRate uom="Hz">0.0</ioos:SamplingRate>
                          <ioos:ReportingInterval uom="s">360.0</ioos:ReportingInterval>
                          <ioos:ProcessingLevel>RAW</ioos:ProcessingLevel>
                          <ioos:Context name="BinSize" uom="m">1.0</ioos:Context>
                          <ioos:Context name="FirstBinCenter" uom="m">1.4</ioos:Context>
                          <ioos:Count name="NumberOfBins">13</ioos:Count>
                          <ioos:ContextArray gml:id="Station1Sensor1BinDistance">
                            <gml:description>Estimated depth of bin relative to the water surface</gml:description>
                            <gml:valueComponents>
                              <ioos:Context name="Bin1" uom="m">4.46</ioos:Context>
                              <ioos:Context name="Bin2" uom="m">5.46</ioos:Context>
                              <ioos:Context name="Bin3" uom="m">6.46</ioos:Context>
                              <ioos:Context name="Bin4" uom="m">7.46</ioos:Context>
                              <ioos:Context name="Bin5" uom="m">8.46</ioos:Context>
                              <ioos:Context name="Bin6" uom="m">9.46</ioos:Context>
                              <ioos:Context name="Bin7" uom="m">10.46</ioos:Context>
                              <ioos:Context name="Bin8" uom="m">11.46</ioos:Context>
                              <ioos:Context name="Bin9" uom="m">12.46</ioos:Context>
                              <ioos:Context name="Bin10" uom="m">13.46</ioos:Context>
                              <ioos:Context name="Bin11" uom="m">14.46</ioos:Context>
                              <ioos:Context name="Bin12" uom="m">15.46</ioos:Context>
                              <ioos:Context name="Bin13" uom="m">16.46</ioos:Context>
                            </gml:valueComponents>
                          </ioos:ContextArray>
                        </gml:valueComponents>
                      </ioos:CompositeContext>
                    </gml:valueComponents>
                  </ioos:ContextArray>
                </gml:valueComponents>
              </ioos:CompositeContext>
            </gml:valueComponents>
          </ioos:ContextArray>
        </gml:valueComponents>
      </ioos:CompositeContext>
    </om:Process>
  </om:procedure>
  <om:observedProperty xlink:href="[URL unfurl="true"]http://www.csc.noaa.gov/ioos/schema/IOOS-DIF/IOOS/0.6.1/dictionaries/phenomenaDictionary.xml#Currents"/>[/URL]
  <om:featureOfInterest xlink:href="urn:cgi:feature:CGI:EarthOcean"/>
  <om:result>
    <ioos:Composite recDef="[URL unfurl="true"]http://www.csc.noaa.gov/ioos/schema/IOOS-DIF/IOOS/0.6.1/recordDefinitions/CurrentsVerticalProfileTimeSeriesDataRecordDefinition.xml"[/URL] name="CurrentsVerticalProfileCollectionTimeSeriesDataObservation" gml:id="CVPCTSDO">
      <gml:valueComponents>
        <ioos:Count name="NumberOfObservationPoints">1</ioos:Count>
        <ioos:Array name="CurrentsVerticalProfileCollectionTimeSeries" gml:id="CPCTS">
          <gml:valueComponents>
            <ioos:Composite name="Station1TimeSeriesRecord" gml:id="S1TSR">
              <gml:valueComponents>
                <ioos:Count name="Station1NumberOfObservationTimes">1</ioos:Count>
                <ioos:Array name="Station1CurrentsProfileTimeSeries" gml:id="S1CPTS">
                  <gml:valueComponents>
                    <ioos:Composite name="Station1T1Profile" gml:id="S1T1P">
                      <gml:valueComponents>
                        <ioos:CompositeContext name="Station1T1ObservationConditions" gml:id="S1T1OC" processDef="#Station1Info">
                          <gml:valueComponents>
                            <gml:TimeInstant gml:id="Station1T1Time">
                              <gml:timePosition>2008-04-01T12:05:00Z</gml:timePosition>
                            </gml:TimeInstant>
                            <ioos:Context name="Heading" uom="deg">10.1</ioos:Context>
                            <ioos:Context name="Pitch" uom="deg">-0.6</ioos:Context>
                            <ioos:Context name="Roll" uom="deg">3.0</ioos:Context>
                            <ioos:Context name="WaterTemperature" uom="C">11.66</ioos:Context>
                          </gml:valueComponents>
                        </ioos:CompositeContext>
                        <ioos:Count name="Station1T1NumberOfBinObservations">13</ioos:Count>
                        <ioos:ValueArray name="Station1T1ProfileObservations" gml:id="S1T1PO">
                          <gml:valueComponents>
                            <ioos:CompositeValue name="Station1T1Bin1Obs" gml:id="S1T1B1" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">347.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">37.5</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin2Obs" gml:id="S1T1B2" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">358.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">36.0</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin3Obs" gml:id="S1T1B3" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">18.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">31.1</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin4Obs" gml:id="S1T1B4" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">37.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">21.8</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin5Obs" gml:id="S1T1B5" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">49.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">26.8</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin6Obs" gml:id="S1T1B6" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">31.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">25.7</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin7Obs" gml:id="S1T1B7" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">20.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">29.1</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin8Obs" gml:id="S1T1B8" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">31.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">27.1</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin9Obs" gml:id="S1T1B9" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">9.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">28.0</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin10Obs" gml:id="S1T1B10" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">357.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">30.0</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin11Obs" gml:id="S1T1B11" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">355.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">27.2</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin12Obs" gml:id="S1T1B12" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">347.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">29.6</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                            <ioos:CompositeValue name="Station1T1Bin13Obs" gml:id="S1T1B13" processDef="#Station1Sensor1Info">
                              <gml:valueComponents>
                                <ioos:Quantity name="CurrentDirection" uom="deg">334.0</ioos:Quantity>
                                <ioos:Quantity name="CurrentSpeed" uom="cm/s">27.5</ioos:Quantity>
                              </gml:valueComponents>
                            </ioos:CompositeValue>
                          </gml:valueComponents>
                        </ioos:ValueArray>
                      </gml:valueComponents>
                    </ioos:Composite>
                  </gml:valueComponents>
                </ioos:Array>
              </gml:valueComponents>
            </ioos:Composite>
          </gml:valueComponents>
        </ioos:Array>
      </gml:valueComponents>
    </ioos:Composite>
  </om:result>
</om:CompositeObservation>

One final question. How did you know that the first item in the xsi:schemaLocation content needed to be " as opposed to " Using the former ' was what made NetBeans happy. XMLSpy would report a successful validation with anything there. All XMLSpy needed was the fully qualified URL to the schema as the second item in the xsi:schemaLocation content.



'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
>One final question...
The xsd should advertise what namespace the schema is intended to describe. That is through the targetNamespace attribute and it is where you look up at the first instance.
 
That works. Thanks for the help. The project is moving along as it should, once again, thanks to Tek-tips and people like you.



'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top