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

How to "query" into a different xml?

  • From: =?UNKNOWN?Q?Jos=E9?= Manuel Beas <jmbeas@t...>
  • To: xml-dev@l...
  • Date: Wed, 18 Oct 2000 16:39:28 +0200

xsl 1013
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@t...)
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


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.