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

Choosing content depending on content of other element

Subject: Choosing content depending on content of other element
From: "Jochen Metzger" <j.metzger@xxxxxxxxxxxx>
Date: Thu, 25 Jul 2002 09:53:05 +0200
what is choosing content
Hi list,

I think I'm stuck.
I've been trying on the following problem, but I can't figure it out.

I've merged two xml-trees. That's fine so far.

No I have the nodes /root/output/data/product_id and order/product

Depending on the product_id output, I wan't to choose
the equivalent node

/root/order/product/@id='xxx'/content/@group

Example:
When I have output

So when /root/output/data/product_id  => 404
I want to output all the equivalent
/root/order/product/id='404'/content/@group

Beneath there's the xml-tree.

Beneath is also the current version of the xsl-stylesheet. I've tried so far
(without) success:
Why does it not work?

Regards Jochen

xml
===
<?xml version="1.0"?>
<root>
   <output>
      <data>
   <ordernr>9026</ordernr>
   <productnr>PD1X404</productnr>
    <product_id>404</product_id>
      </data>

      <data>
         <ordernr>9026</ordernr>
         <productnr>PD1X405</productnr>
         <product_id>405</product_id>
      </data>
   </output>

   <order nr="9026">
     <product id="404">
        <content group="9026-P404-M402-1">
          <shops_booked>4</shops_booked>
            <status_in_lang>in Bearbeitung</status_in_lang>
   </content>

         <content group="9026-P404-M402-2">
          <shops_booked>2</shops_booked>
   <status_in_lang>Online</status_in_lang>
         </content>

      </product>

      <product id="405">
        <content group="9026-P405-M402-1" />
   </product>
 </order>

</root>

XSL
=======
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="xhtml" version="1.0" encoding="UTF-8" indent="no"
omit-xml-declaration="yes" doctype-public="-//W3C/DTD XHTML 1.0
Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
standalone="yes" media-type="text/html" />

   <xsl:template match="/">
      <xsl:apply-templates select="/root/output" />
   </xsl:template>

   <xsl:template match="/root/output">
      <xsl:call-template name="line" />
   </xsl:template>

   <xsl:template name="line">
   <br/>
   <xsl:for-each select="data">
            <br/><br/><b><small><u>Produkt</u></small></b><br/>
            <xsl:value-of select="productnr" />
            <br/><b><small>Content-Gruppe</small></b>
           <xsl:apply-templates
select="/root/order/product[@id='/root/output/data/product_id']"/>
  </xsl:for-each>
   </xsl:template>

   <xsl:template
match="/root/order/product[@id='/root/output/data/product_id']">
     <br/><xsl:value-of select="content/@group"/>
   </xsl:template>
</xsl:stylesheet>

xml
===
<?xml version="1.0"?>
<root>
   <output>
      <data>
   <ordernr>9026</ordernr>
   <productnr>PD1X404</productnr>
    <product_id>404</product_id>
      </data>

      <data>
         <ordernr>9026</ordernr>
         <productnr>PD1X405</productnr>
         <product_id>405</product_id>
      </data>
   </output>

   <order nr="9026">
     <product id="404">
        <content group="9026-P404-M402-1">
          <shops_booked>4</shops_booked>
            <status_in_lang>in Bearbeitung</status_in_lang>
   </content>

         <content group="9026-P404-M402-2">
          <shops_booked>2</shops_booked>
   <status_in_lang>Online</status_in_lang>
         </content>

      </product>

      <product id="405">
        <content group="9026-P405-M402-1" />
   </product>
 </order>

</root>




 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.