OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   How to "query" into a different xml?

[ Lists Home | Date Index | Thread Index ]
  • From: =?UNKNOWN?Q?Jos=E9?= Manuel Beas <jmbeas@telenium.es>
  • To: xml-dev@lists.xml.org
  • Date: Wed, 18 Oct 2000 16:39:28 +0200

Hello everyone,

We have an xml file with a catalogue of parts, but their descriptions
are kept in a different xml file (this file depends on the class of
the part).

These is the file:

"parts.xml"
------------
<parts>
  <part name="BigSquare">
    <class>square</class>
    <query>square[@id = '001']/color</query>
  </part>
  <part name="SmallCylinder">
    <class>cylinder</class>
    <query>cylinder[@id = '001']/color</query>
  </part>
</parts>
-----------

I am transforming it into HTML with an XSLT by matching the "part"
template.

"process.xslt"
-----------
<xsl:template match="part">
  <H1><xsl:value-of select="@name"/></H1>
  <xsl:variable name="OBJECTNAME" select="class"/>
  <xsl:variable name="QUERYSTRING" select="query"/>
  <xsl:variable name="FILENAME" select="document('master.xml')//object
[@name = $OBJECTNAME]/@href"/>
  objectname = <xsl:value-of select="$OBJECTNAME"/><BR/>
  filename = <xsl:value-of select="$FILENAME"/><BR/>
  query = <xsl:value-of select="$QUERYSTRING"/><BR/>
  <PRE>
  <xsl:value-of select="document($FILENAME)//$QUERYSTRING"/>
  </PRE>
</xsl:template>
-----------

What I am doing is to look for the filename corresponding to each
part "class" (into "master.xml") and then apply the "query" to that
xml file.

But it doesn't work. I get the following error:

oracle.xml.parser.v2.XSLException: XSL-1013: Error in
expression: 'document($FILENAME)//$QUERYSTRING'.


The rest of the files used are:

"master.xml"
------------
<master>
  <objects>
    <object name="square" href="squares.xml"/>
    <object name="cylinder" href="cylinders.xml"/>
  </objects>
</master>
------------
"squares.xml"
------------
<squares>
  <square id="001">
    <color>Black</color>
    <size>big</size>
  </square>
  <square id="002">
    <color>Blue</color>
    <size>small</size>
  </square>
</squares>
-----------

It's curious, but when I replace
  <xsl:value-of select="document($FILENAME)//$QUERYSTRING"/>
by (for example)
  <xsl:value-of select="document($FILENAME)//square[@id
= '001']/color"/>
I get the following:
-----
<PRE>
  Black
</PRE>
-----

Which is EXACTLY what I am trying to obtain.

Any ideas???

Thanks in advance,
José Manuel Beas (jmbeas@telenium.es)
Software Engineer
TELENIUM, The New Millennium Telecom Company
Agustín de Foxá, 25, plta. 13
28036 MADRID
Tel. +34 91 315 85 62 (ext. 262/263)
Fax +34 91 315 63 37
http://www.telenium.es





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS