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

Re: Value dependency between nested attributes

Subject: Re: Value dependency between nested attributes
From: Syd Bauman <Syd_Bauman@xxxxxxxxx>
Date: Sun, 18 Oct 2009 10:23:57 -0400
Re:  Value dependency between nested attributes
I'm not 100% sure what you want to do, but I *think* the following
will put you on a path to get you there. If not the best path, at
least a path.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

  <xsl:param name="XX">oops ? you forgot to supply an XX</xsl:param>
  <xsl:param name="YY">oops ? you forgot to supply a  YY</xsl:param>
  <xsl:param name="VV">oops ? you forgot to supply a  VV</xsl:param>
  <xsl:param name="WW">oops ? you forgot to supply a  WW</xsl:param>
  
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="A">
    <xsl:copy-of select="@*"/>
    <xsl:choose>
      <xsl:when test="@name='a'">
        <xsl:attribute name="test2"><xsl:value-of select="$XX"/></xsl:attribute>
        <xsl:attribute name="test3"><xsl:value-of select="$YY"/></xsl:attribute>
      </xsl:when>
      <xsl:when test="@name='b'">
        <xsl:attribute name="test2"><xsl:value-of select="$VV"/></xsl:attribute>
        <xsl:attribute name="test3"><xsl:value-of select="$WW"/></xsl:attribute>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>


> Output format shall be same than input format (XML-->XML Transformation):
>  <A name="a" test1="vw" test2="cd" test3="ef" test4="gh"/>
>  <A name="b" test1="vw" test2="cd" test3="ef" test4="gh" test7="ee"/>
>  <A name="c" test1="vw" test2="cd" test3="ef" test4="gh"/>
>  <A name="d" test1="xy" test2="ij" test3="kl" test4="mn" test5="op"/>
> I want to give some params to the processor to change some (not
> all) "test" values. The values for the change depend on the value
> of the "name" attribute.
> For example: if value of name = "a" then test2 value="$XX" and
> test3 value="$YY" and if name="b" then test2 value="$VV" and test3
> value="$WW"
> There are 4 different values for 'name' --> 4 A lines
> It is my first try to build a xsl file -- so sorry if this question
> is stupid. I tried to customize the "Identity change template"
> (http://www.dpawson.co.uk/xsl/sect2/identity.html#d5687e43 ) for my
> needs, but i am not experienced enough to get this running for my
> situation.
> If someone could show me some templates to solve this problem...
> Thank you very much

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.