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

RE: Select nodes without match

Subject: RE: Select nodes without match
From: cknell@xxxxxxxxxx
Date: Thu, 24 Aug 2006 09:16:14 -0400
xsl template without match
> 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@xxxxxxxxxx - email



-----Original Message-----
From:     <m.core@xxxxxxxxxxxxxxxx>
Sent:     Thu, 24 Aug 2006 12:15:37 +0200
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  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

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.