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

Axis problem

Subject: Axis problem
From: Juergen Baier <x_baier@xxxxxxxxxxxxxxxx>
Date: Thu, 07 Sep 2000 12:51:05 +0200
axis problem
Hi,

I'm a XSLT beginner and I recently run into a problem. I couldn't find
an example where my problem is explained (probably I just didn't see it
in the FAQs).

I have a XML source like this:

<component class="someClass" name="myName">
      <properties>
        <property name="someProperty" type="someType">
          <specialProperty name="someSpecialProperty"/>
        </property>
        <property name="otherProperty" type="otherType">
          <otherSpecialProperty name="someOtherSpecialProperty/>
        </property>
	<!-- many other properties -->
      </properties>
</component>
<!-- some other components ...-->

I have written a stylesheet:

<xsl:template match="component">
<xsl:choose>
  <xsl:when test="@class = 'someClass'">
    <xsl:choose>
      <xsl:when test="properties/property/@type = 'someType'">
        someClass name: <xsl:value-of select="@name"/> 
        , property name: <xsl:value-of
select="properties/property/someProperty/@name"/>
        , specialProperty name: <xsl:value-of
select="properties/property/someProperty/specialProperty/@name">
        <!-- do some special things ... --> 
      </xsl:when>
      <!-- some other whens -->
    </xsl:choose>
  </xsl:when>
</xsl:choose>
</xsl:template>

which correctly prints out the name of component and the name of a
special type of property.
But: different classes often have the same properties. So instead of
checking the property type inside the <xsl:when test="@class =
'someClass'>..</xsl:when> I want a more generic approach, like this:

<xsl:template match="properties">
<xsl:for-each select="property">
<xsl:choose>
  <xsl:when test="@type = 'someType'">
    someClass name: <xsl:value-of select="XXXXX"/>
    , property name: <xsl:value-of select="@name"/>
    , specialProperty name: <xsl:value-of
select="specialProperty/@name"/>"
  </xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>

The output should be:

someClass name: myName, property name: someProperty, specialProperty
name: someSpecialProperty
otherClass name: myName, property name: someOtherProperty,
specialProperty name: someOtherSpecialProperty
someClass name: myName2, property name: someProperty, specialProperty
name: someSpecialProperty

Instead of the XXXXX I tried several XPath-Expressions (parent,
ancestor, ...), but I never get the @name of the component which
properties I am processing now. The other stuff (propertyName and
specialPropertyName) works correctly.

Hmm. Hope that was not too confusing ...

If you've any idea what I'm doing wrong, please give me a hint.

Thanks a lot,

Juergen
-- 


Juergen Baier
x_baier@xxxxxxxxxxxxxxxx

Propack Data GmbH


 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.