Can't change variables so how do I work around it.

Discussion in 'XML' started by Jason Lehman, Feb 14, 2005.

  1. Jason Lehman

    Jason Lehman Guest

    I want to depending on a parameter in the XML change wether the div should
    display or not. Do I have to repeat the whole block in two if containers
    with the style display:none and one with display:block but then whenever I
    have to make a change to the block I have to update in two places? Any help
    would be appreciated.

    My example:

    <xsl:if test="RequirementGroup/@ReqMet = &quot;Y&quot;">

    <div style="display:none;margin-left:1em;" id="Area_Info{$intArea_Info}">

    <xsl:if test="string-length(Code) &gt; 0">

    <br />Code:<xsl:for-each select="Code">

    <xsl:apply-templates />

    </xsl:for-each>

    </xsl:if>

    <br />

    <span style="background-color:#336633; color:#FFFFFF; width:100%;
    ">Requirement Group:</span>

    <xsl:apply-templates select="RequirementGroup" />

    <br />Course Group:<xsl:apply-templates select="CourseGroup" />

    <xsl:if test="string-length(Review) &gt; 0">

    <br />Review: <xsl:apply-templates select="Review" />

    </xsl:if>

    <br />Summary: <xsl:apply-templates select="Summary" />

    <br />

    </div>

    </xsl:if>

    <xsl:if test="RequirementGroup/@ReqMet = &quot;N&quot;">

    <div style="display:block;margin-left:1em;" id="Area_Info{$intArea_Info}">

    <xsl:if test="string-length(Code) &gt; 0">

    <br />Code:<xsl:for-each select="Code">

    <xsl:apply-templates />

    </xsl:for-each>

    </xsl:if>

    <br />

    <span style="background-color:#336633; color:#FFFFFF; width:100%;
    ">Requirement Group:</span>

    <xsl:apply-templates select="RequirementGroup" />

    <br />Course Group:<xsl:apply-templates select="CourseGroup" />

    <xsl:if test="string-length(Review) &gt; 0">

    <br />Review: <xsl:apply-templates select="Review" />

    </xsl:if>

    <br />Summary: <xsl:apply-templates select="Summary" />

    <br />

    </div>

    </xsl:if>
     
    Jason Lehman, Feb 14, 2005
    #1
    1. Advertising

  2. Your question isn't very clear, however the answer to

    I want to depending on a parameter in the XML change wether the div should
    display or not. Do I have to repeat the whole block in two if containers
    with the style display:none and one with display:block but then whenever I
    have to make a change to the block I have to update in two places?

    Is probably no.

    If you only want to make the attriibute depend on the parameter just
    place the conditional at that point.

    <div id="Area_Info{$intArea_Info}">
    <xsl:attribute name="style">
    <xsl:text>display:</xsl:text>
    <xsl:choose>
    <xsl:when test="something">none</xsl:when>
    <xsl:eek:therwise>block</xsl:eek:therwise>
    </xsl:choose>
    <xsl:text>;margin-left:1em;</xsl:text>
    </xsl:attribute>
    ....



    <xsl:if test="string-length(Code) &gt; 0">
    incidentally, probably better to do
    <xsl:if test="string(Code)">
    (which is equivalent)
    or
    <xsl:if test="Code">
    which isn't equivalent (it's true even if the first code is empty, unlike the first two)


    David
     
    David Carlisle, Feb 14, 2005
    #2
    1. Advertising

  3. Jason Lehman

    Jason Lehman Guest

    I tried your example but it is not working for me. My test that I have in
    my original example doesn't work in your example even though it is in the
    same template block.

    My Code:
    <xsl:template match="Area">

    <xsl:if test="RequirementGroup/@ReqMet = &quot;Y&quot;">

    <span style="color:#FFCC00; font-size:15px; " id="Requirement_Met">

    <div id="Area_Info_plus{$intArea_Info}"
    style="width=1em;display:inline;">+</div><div
    id="Area_Info_minus{$intArea_Info}" style="width=1em;display:none;">-</div>
    Yes</span>

    </xsl:if>

    </xsl:template>

    But if I put the test above in your code it doesn't change the attribute.



    "David Carlisle" <> wrote in message
    news:...
    >
    > Your question isn't very clear, however the answer to
    >
    > I want to depending on a parameter in the XML change wether the div

    should
    > display or not. Do I have to repeat the whole block in two if

    containers
    > with the style display:none and one with display:block but then whenever

    I
    > have to make a change to the block I have to update in two places?
    >
    > Is probably no.
    >
    > If you only want to make the attriibute depend on the parameter just
    > place the conditional at that point.
    >
    > <div id="Area_Info{$intArea_Info}">
    > <xsl:attribute name="style">
    > <xsl:text>display:</xsl:text>
    > <xsl:choose>
    > <xsl:when test="something">none</xsl:when>
    > <xsl:eek:therwise>block</xsl:eek:therwise>
    > </xsl:choose>
    > <xsl:text>;margin-left:1em;</xsl:text>
    > </xsl:attribute>
    > ...
    >
    >
    >
    > <xsl:if test="string-length(Code) &gt; 0">
    > incidentally, probably better to do
    > <xsl:if test="string(Code)">
    > (which is equivalent)
    > or
    > <xsl:if test="Code">
    > which isn't equivalent (it's true even if the first code is empty, unlike

    the first two)
    >
    >
    > David
     
    Jason Lehman, Feb 14, 2005
    #3
  4. Jason Lehman

    Jason Lehman Guest

    Ignore this I realize my error now. I had my statements backwards and now
    it is working correctly.

    "Jason Lehman" <0spam.usf.edu> wrote in message
    news:cur4hh$pn4$...
    > I tried your example but it is not working for me. My test that I have in
    > my original example doesn't work in your example even though it is in the
    > same template block.
    >
    > My Code:
    > <xsl:template match="Area">
    >
    > <xsl:if test="RequirementGroup/@ReqMet = &quot;Y&quot;">
    >
    > <span style="color:#FFCC00; font-size:15px; " id="Requirement_Met">
    >
    > <div id="Area_Info_plus{$intArea_Info}"
    > style="width=1em;display:inline;">+</div><div
    > id="Area_Info_minus{$intArea_Info}"

    style="width=1em;display:none;">-</div>
    > Yes</span>
    >
    > </xsl:if>
    >
    > </xsl:template>
    >
    > But if I put the test above in your code it doesn't change the attribute.
    >
    >
    >
    > "David Carlisle" <> wrote in message
    > news:...
    > >
    > > Your question isn't very clear, however the answer to
    > >
    > > I want to depending on a parameter in the XML change wether the div

    > should
    > > display or not. Do I have to repeat the whole block in two if

    > containers
    > > with the style display:none and one with display:block but then

    whenever
    > I
    > > have to make a change to the block I have to update in two places?
    > >
    > > Is probably no.
    > >
    > > If you only want to make the attriibute depend on the parameter just
    > > place the conditional at that point.
    > >
    > > <div id="Area_Info{$intArea_Info}">
    > > <xsl:attribute name="style">
    > > <xsl:text>display:</xsl:text>
    > > <xsl:choose>
    > > <xsl:when test="something">none</xsl:when>
    > > <xsl:eek:therwise>block</xsl:eek:therwise>
    > > </xsl:choose>
    > > <xsl:text>;margin-left:1em;</xsl:text>
    > > </xsl:attribute>
    > > ...
    > >
    > >
    > >
    > > <xsl:if test="string-length(Code) &gt; 0">
    > > incidentally, probably better to do
    > > <xsl:if test="string(Code)">
    > > (which is equivalent)
    > > or
    > > <xsl:if test="Code">
    > > which isn't equivalent (it's true even if the first code is empty,

    unlike
    > the first two)
    > >
    > >
    > > David

    >
    >
     
    Jason Lehman, Feb 14, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TB
    Replies:
    2
    Views:
    3,743
  2. Piet
    Replies:
    0
    Views:
    549
  3. Network/Software Buyer
    Replies:
    0
    Views:
    420
    Network/Software Buyer
    May 23, 2010
  4. R. Myers

    INamingContainer problem...can I work around this?

    R. Myers, Nov 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    178
    R. Myers
    Nov 27, 2004
  5. D. Alvarado

    Can anyone tell me a Mac IE work-around?

    D. Alvarado, Apr 26, 2004, in forum: Javascript
    Replies:
    0
    Views:
    84
    D. Alvarado
    Apr 26, 2004
Loading...

Share This Page