xsl-list
[Top] [All Lists]

Re: Copying nodes

2002-12-10 13:47:56
Code like this is never going to work:

<xsl:template match="@URL">
 <xsl:copy>http://www.mydomain.com</xsl:copy>
</xsl:template>

xsl:copy copies completely the attribute node. To quote the spec:
"The content of the xsl:copy element is a template for the attributes
and children of the created node; the content is instantiated only for
nodes of types that can have attributes or children (i.e. root nodes
and element nodes)."

http://www.w3.org/TR/xslt#copying



Therefore, you need:

<xsl:template match="@URL">
   <xsl:attribute name="URL">http://www.mydomain.com</xsl:attribute>
</xsl:template>



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


"Juan Carlos Gonzalez" <jcgonz(_at_)yahoo(_dot_)com> wrote in message
news:20021210192340(_dot_)3549(_dot_)qmail(_at_)web14004(_dot_)mail(_dot_)yahoo(_dot_)com(_dot_)(_dot_)(_dot_)
The code that you sent me did not change the value of
the URL attribute within the copied node. Any other
suggestions?

--- Américo_Albuquerque
<aalbuquerque(_at_)viseu(_dot_)ipiaget(_dot_)pt> wrote:
Hi.
I don't know what you trying to do but try this, it
will copy everything
and will change your attribute:

<xsl:template match="categ">
  <xsl:copy>
    <xsl:apply-templates select="@*"/> 
    <xsl:copy-of select="*"/>
  </xsl:copy> 
</xsl:template>

<xsl:template match="@*">
  <xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="@URL">
 <xsl:copy>http://www.mydomain.com</xsl:copy>
</xsl:template>


-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On
Behalf Of Juan Carlos
Gonzalez
Sent: terça-feira, 10 de Dezembro de 2002 18:11
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Copying nodes


I'm sorry but still doesn not work.

-----Original Message-----
From: Américo Albuquerque
[mailto:aalbuquerque(_at_)viseu(_dot_)ipiaget(_dot_)pt]
Sent: Tuesday, December 10, 2002 11:42 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Copying nodes


Hi.
Use:
<xsl:template match="@URL">
<xsl:copy>http://www.mydomain.com</xsl:copy>
</xsl:template>

Hope that this helps

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On
Behalf Of Juan Carlos
Gonzalez
Sent: terça-feira, 10 de Dezembro de 2002 14:44
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Copying nodes


Hi:

I have the following templates for copying nodes and
it's attributes which work OK:

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

<xsl:template match="categ|@*">
  <xsl:copy>
    <xsl:apply-templates select="@*"/> 
    <xsl:copy-of select="*"/>
  </xsl:copy> 
</xsl:template>

What I'm trying to do is to change the value for a
specific attribute, for that purpose I have created
another template but it doesn't seem to execute at
all:

<xsl:template match="@URL">
   http://www.mydomain.com
<!-- or 
    <xsl:copy-of select="http://www.mydomain.com"/>
-->  
</xsl:template>
 
Thanks.



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up
now.
http://mailplus.yahoo.com

 XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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