Science With the Virtual Observatory |
The exercises presented here are companions to the presentation XML Technologies (PDF, PPT).
In this presentation, we'll be using some tools from the ADQL library
that comes with in your summer school software package. To build them,
change into the adqllib package directory and run ant:
on Linux/MacOS:
cd $NVOSS_HOME/java/src/adqllib ant |
on Windows:
cd %NVOSS_HOME%\java\src\adqllib ant |
|
25 seconds or so later, you should see ant print "BUILD SUCCESSFUL" to
the screen. If you are Linux or MacOS, you might want to type
rehash to ensure the new tools are available to you.
| Here are two good resources on XML Schema: | The presentation slides make reference to these example files: |
In this first part we just looked at a really simple Schema and a
corresponding instance document:
xmltech-simple.xsd and
xmltech-simple.xml. Download and
save these to your local drive. Go ahead and load them into an editor
as we'll be looking at them soon. We will now try out the
validate program to test if the instance document is
compliant with the schema:
validate xmltech-simple.xmlDo you see the following output?
xmltech-simple.xml: 478 ms (4 elems, 1 attrs, 0 spaces, 86 chars)
If so, then the document is compliant! (I know, the output is not very forthcoming.) If it were not compliant, you would see some error messages indicating which parts of the XML document were incorrect.
For the rest of this exercise, edit the
xmltech-simple.xml to create both variations on the file
that are correct and incorrect. For example, add or remove elements
where allowed or disallowed. With each change, run
validate to check your results.
Here is VOResource-v1.0.xsd, the actual IVOA metadata schema used to describe VO resources. Also have a look at xmltech-adil.xml, an example instance document that uses not only this schema but also an extension schema, VODataService-v1.0.xsd.
Notice that the instance document makes use of the
xsi:type extension technique.
Find the definition of the DataCollection type (in
VODataService-v1.0.xsd).
Try adding additional metadata to xmltech-adil.xml, in particular elements that are not included now.
stc:STCResourceProfile
section. validate program to check your results.
Note: Validating this XML file
with the validate program requires access to the
network. This is because (as you will see if you look at
document's xsi:schemaLocation attribute) it will
pull the schema documents directly from the IVOA web site.
Look again at our VOResource instance file, xmltech-adil.xml. Write down the absolute XPath corresponding to the elements or attributes containing the following string values:
What would be the relative XPath to the above
values if the current context node were the content
element?
The Carnivore Registry stores its XML resource descriptions in an XML database which supports XQuery. In this exercise, we will try out a few queries.
In another browser window, load the Carnivore XQuery page, http://nvo.caltech.edu:8080/carnivore/advancedquery.
Try a very simple, pre-canned query from Examples pull-down menu. I recommend the last one, in which we search for mention of quasars. Hit the "Submit" button to execute it, and inspect the resuls.
Now let's try our example from the slides:
declare namespace vr= "http://www.ivoa.net/xml/VOResource/v0.10";
declare namespace vs= "http://www.ivoa.net/xml/VODataService/v0.5";
for $vr in //vr:Resource[@xsi:type="cs:ConeSearch"]
where contains($vr//vr:description, "quasar")
return
<conesearch>
<title>{string($vr/vr:title)}</title>
<url>{string($vr/vr:interface/vs:accessURL)}</url>
</conesearch>
Cut-and-paste this query into the query box and submit it.
xalan command to apply our
stylesheet:
xalan -in xmltech-adil.xml -xsl xmltech-VOResource.xslYou should now see the following:
Resource Description Record DataCollection NCSA Astronomy Digital Image Library (ADIL) IVOA Identifier: ivo://adil.ncsa/adil Description: The ADIL collects published image data in FITS format from a variety of telescopes and wavebands and makes them available to the astronomical community. Users can search, browse, and download images as well as upload their own published images. Target Communities: University, Research Published by: NCSA Radio Astronomy Imaging
xalan to check the results. The NVO Summer School is made possible through the support of the National Science Foundation and the National Aeronautics and Space Administration.
![]() |