xsl-list
[Top] [All Lists]

RE: [xsl]Select nodes without match

2006-08-24 09:07:58
Is there a command like a go-to in xsl for doing this?
Answer: No, "go-to" is from a different processing model. You'll need to find 
another means.

if i make a template with match it destroy the object .cap 
Answer: No, it won't destroy anything.

You haven't shown us your XML, so I'll invent some that has the relevant 
properties and write an XLST template that should give you what you want.

------- INPUT DOCUMENT---------
<?xml version="1.0"?>
<root-node>
  <box id="ball.cap">Pittsburgh Pirates</box>
  <box id="pennant">Pittsburgh Pirates</box>
</root-node>

-------- STYLESHEET-------------
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:strip-space elements="*" />
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />

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

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

    <xsl:template match="box">
      <xsl:choose>
        <xsl:when test="ends-with(@id,'.cap')">
                <box>
                  <xsl:attribute name="width" select="'2%'" />
                  <xsl:for-each select="@*">
                    <xsl:if test="not(local-name(.) = 'id')">
                      <xsl:copy-of select="." />
                    </xsl:if>
               </xsl:for-each>
                  <xsl:value-of select="." />
                </box>
        </xsl:when>
        <xsl:otherwise><xsl:copy-of select="." /></xsl:otherwise>
      </xsl:choose>
    </xsl:template>

</xsl:stylesheet>

--------OUTPUT DOCUMENT-----------
<?xml version="1.0" encoding="UTF-8"?>
<root-node>
   <box width="2%">Pittsburgh Pirates</box>
   <box id="pennant">Pittsburgh Pirates</box>
</root-node>


Charles Knell
cknell(_at_)onebox(_dot_)com - email



-----Original Message-----
From:     <m(_dot_)core(_at_)aimconsulting(_dot_)it>
Sent:     Thu, 24 Aug 2006 12:15:37 +0200
To:       xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject:  [xsl]Select nodes without match

Hi all,
i have an xml tree and i need with xsl to be placed in a particular node 
without using the match statement.


For explain me well:
in the html version of the page i have a box in wich you can write; i need to 
resize that box and for doing this i write:

<xsl:when test="utils:endsWith(@id, '.cap')">
  <xsl:attribute name="width">2%</xsl:attribute>
</xsl:when>

but i need to place this code in a template that put me in the right nodes that 
contains .cap and i don't want this... How can i do?

thx for replies.
Matteo
 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>