Subject: [xsl] problem solved with your help From: Robert Sösemann <robert.soesemann@xxxxxx> Date: Sat, 2 Mar 2002 12:10:35 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] sort and collating sequen, Michael Kay | Thread | [xsl] XALAN!!, William Rutford |
RE: [xsl] sort and collating sequen, Michael Kay | Date | [xsl] XALAN!!, William Rutford |
Month |