[glue-wg] Concrete example for alternative primary source [option P.O]
Paul Millar
paul.millar at desy.de
Tue Dec 11 15:32:35 CST 2007
Hi,
Here's a concrete example, a primary source (a Service) publishes XML with a
top-level element of <Service>
Variant #1 (with attributes)
<Service id="Service-URI" parent="AdminDomain-URI" name="Fred">
<!-- service details here -->
</Service>
Variant #2 (with no attributes)
<Service>
<ID>Service-URI</ID>
<Parent>AdminDomain-URI</Parent>
<Name>Fred</Name>
<!-- further details here -->
</Service>
When aggregation happens, the services are collected under their "Parent"
(some AdminDomain). This allows the site information to using the simple
One-to-Many mapping to parent/child elements concept.
Here is a worked example.
Consider three services: a CE & SE service (under AdminDomain-1) and an FTS
service (under AdminDomain-2).
File: service-1.xml
<?xml version="1.0"?>
<Service>
<ID>http://example.org/Service-1</ID>
<Parent>http://example.org/AdminDomain-1</Parent>
<Name>MyCE</Name>
</Service>
File: service-2.xml
<?xml version="1.0"?>
<Service>
<ID>http://example.org/Service-2</ID>
<Parent>http://example.org/AdminDomain-1</Parent>
<Name>MySE</Name>
</Service>
File: service-3.xml
<?xml version="1.0"?>
<Service>
<ID>http://example.org/Service-3</ID>
<Parent>http://example.org/AdminDomain-2</Parent>
<Name>FTS</Name>
</Service>
Here the site is defined through the site.xml file. This toy example just
listing the service URIs and the list of AdminDomain we wish to publish. The
AdminDomains here are void of any additional information. That information
could be included in site.xml, or imported from elsewhere.
To keep things simple, Service elements href attributes use relative URIs to
access each service's GLUE/XML info; but the URIs could be absolute and the
information collected directly (e.g. via HTTP).
File: site.xml
<?xml version="1.0"?>
<Site>
<ServiceList>
<Service href="service1.xml"/>
<Service href="service2.xml"/>
<Service href="service3.xml"/>
<!-- etc. just list all services here -->
</ServiceList>
<AdminDomainList>
<AdminDomain id="http://example.org/AdminDomain-1"/>
<AdminDomain id="http://example.org/AdminDomain-2"/>
<AdminDomain id="http://example.org/AdminDomain-3"/>
</AdminDomainList>
</Site>
Then, just transform this into the GLUE/XML for aggregation:
File: process.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<Grid>
<Site>
<xsl:apply-templates/>
</Site>
</Grid>
</xsl:template>
<xsl:template match="AdminDomain">
<AdminDomain>
<ID><xsl:value-of select="@id"/></ID>
<xsl:apply-templates select="/Site/ServiceList/Service"
mode="import-admin-service">
<xsl:with-param name="adminservice-uri" select="@id"/>
</xsl:apply-templates>
</AdminDomain>
</xsl:template>
<xsl:template match="ServiceList/Service[@href]"
mode="import-admin-service">
<xsl:param name="adminservice-uri"/>
<xsl:copy-of select="document(@href)/Service[Parent=$adminservice-uri]"/>
</xsl:template>
</xsl:stylesheet>
Transform the site.xml into GLUE/XML aggregated format using XSLT:
xsltproc process.xsl site.xml > /tmp/out.xml && xmllint -format /tmp/out.xml
Gives the following output:
<?xml version="1.0"?>
<Grid>
<Site>
<AdminDomain>
<ID>http://example.org/AdminDomain-1</ID>
<Service>
<ID>http://example.org/Service-1</ID>
<Parent>http://example.org/AdminDomain-1</Parent>
<Name>MyCE</Name>
</Service>
<Service>
<ID>http://example.org/Service-2</ID>
<Parent>http://example.org/AdminDomain-1</Parent>
<Name>MySE</Name>
</Service>
</AdminDomain>
<AdminDomain>
<ID>http://example.org/AdminDomain-2</ID>
<Service>
<ID>http://example.org/Service-3</ID>
<Parent>http://example.org/AdminDomain-2</Parent>
<Name>FTS</Name>
</Service>
</AdminDomain>
<AdminDomain>
<ID>http://example.org/AdminDomain-3</ID>
</AdminDomain>
</Site>
</Grid>
[For aesthetics, one could filter out the Parent children from Service
elements.]
Is this about right?
Cheers,
Paul.
More information about the glue-wg
mailing list