[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

problem solved with your help

Subject: problem solved with your help
From: Robert Sösemann <robert.soesemann@xxxxxx>
Date: Sat, 2 Mar 2002 12:10:35 +0100
sigmodrecord.xml
Dear List member and especially Jeni Tennison,

although I always seemed to ask unaswerable questions or to you it seemed
locically incorrect what I was trying to do, with you tips I
managed to create my generic xslt stylesheet for my Java XML Wrapper:

By setting the two variables and the test condition 2 times I can submit
sensible queries to all kinds of different xml sources.
If you are interested try out Xalan with the SigmodRecords from Uni Roma
(www.dia.uniroma3.it/Araneus/Sigmod/Record/SigmodRecord/SigmodRecord.xml)
as source an my xslt:
Only change the 3 customizing points.
As I can never be sure if somebody is searching for an element or attribute
I always check both.
And even if performance is not so good with .// I must do this, because my
input doc don't have an DTD or schema essentially AND I don't want
the person who registers an XML source with my wrapper to give such detailed
path information.

########### The generic customizable stylesheet

<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml"/>

  <!-- my java program should only set those values to customize the
stylesheet //-->
  <xsl:variable name="entity">article</xsl:variable>
  <xsl:variable name="essentialtree">issue</xsl:variable>

  <!-- not elsewhere specified patterns are directly copied //-->
  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*"/>
 </xsl:copy>
  </xsl:template>

  <!-- also output super tree that is also wanted//-->
  <xsl:template match="node()[name()=$essentialtree]">
 <xsl:if test=".//node()[name()=$entity][(contains(.//title, 'Database') or
contains(.//@title, 'Database')) and (.//author='C. J. Date' or
.//@author='C. J. Date')]">
   <xsl:copy>
   <xsl:apply-templates/>
   </xsl:copy>
 </xsl:if>
  </xsl:template>

  <!-- output the entities with the properties that fullfil the query//-->
  <xsl:template match="node()[name()=$entity]">
 <xsl:if test="self::node()[(contains(.//title, 'Database') or
contains(.//@title, 'Database')) and (.//author='C. J. Date' or
.//@author='C. J. Date')]">
 <xsl:copy>
   <xsl:copy-of select="*"/>
 </xsl:copy>
 </xsl:if>
  </xsl:template>

</xsl:transform>

########## An example XMLSourceDescriptor

<?xml version="1.0" encoding="UTF-8"?>
<XMLSourceDescriptor>

 <!-- description that could be shown to explain the resultset //-->
 <description>
     Database of all articles in their issues
 </description>

 <!-- location of the original source XML document described by this, and
various backup url //-->
 <locations>
   <url
position="00">http://www.dia.uniroma3.it/Araneus/Sigmod/Record/SigmodRecord/
SigmodRecord.xml</url>
 </locations>

 <!-- description of the searchable field in the source //-->
 <properties>
    <property name="author" mapto="dc.creator" outputcontainer="article">
    <!-- property description goes here but not mandatory  //-->
    article's author (may be only coauthor)
  </property>
  <property name="title" mapto="dc:title" outputcontainer="article"/>
  <property name="number" mapto="dc:date" outputcontainer="issue">
     the monthly number of an ACM issue within a certain volume
  </property>
 </properties>

</XMLSourceDescriptor>

##### An suitable common query coming generated from the users input

<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE query SYSTEM "dtd/cqml.dtd">

<query>
    <boolean op="and">
      <term value="C. J. Date"
            field="dc:creator"
            relation="eq"/>
      <term value="Database"
            field="dc:title"
            relation="eq"
            truncation="both"/>
    </boolean>
</query>

............................................................................
..........
 ROBERT SÖSEMANN  (robert.soesemann@xxxxxx)

 schwärzlocherstr. 29/1 | 72070 tübingen
 tel : 07071 / 400 880

 icq# : 100 467 870
 pgp-keys : www.webspace-journey.de/pgp.asc
............................................................................
..........



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.