Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > copying all attributes in XSLT

Reply
Thread Tools

copying all attributes in XSLT

 
 
R
Guest
Posts: n/a
 
      03-10-2005
Hello everybody.

I've got my XML file with 'field' node .

Field is transformed with XSLT into paragraph tag in XHTML.

But. A programmer can add various attributes to <field> node, eg.
someone can add 'onclick', 'onmouseover', 'style', 'class', 'align'
attributes and so on. I want to copy all the attributes from <field>
to <p>.
But field has also two attributes that can't be copied: 'id' and
'number'.

And the final question :
How to copy all the attributes without 'id' and 'number' ones?

thanks in advance for any help
best regards
R
 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      03-10-2005
Tempore 18:37:57, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit R <(E-Mail Removed)>:

> And the final question :
> How to copy all the attributes without 'id' and 'number' ones?

<xsl:copy-of select="@*[not(self::id or self::number)]"/>

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
"Quot capita, tot sententiae" - Terentius , Phormio 454
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      03-10-2005


R wrote:


> How to copy all the attributes without 'id' and 'number' ones?


<xsl:template match="field">
<p>
<xsl:copy-of select="@*[local-name() != 'id' and local-name() !=
'number']" />
<xsl:apply-templates />
</p>
</xsl:template>

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      03-10-2005

"Joris Gillis" <(E-Mail Removed)> writes:

> Tempore 18:37:57, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit R <(E-Mail Removed)>:
>
> > And the final question :
> > How to copy all the attributes without 'id' and 'number' ones?

> <xsl:copy-of select="@*[not(self::id or self::number)]"/>
>



You have to use name()!='id' rather than not(self::id) as self::id
selects elements not attributes.

David
 
Reply With Quote
 
Joris Gillis
Guest
Posts: n/a
 
      03-11-2005
Tempore 23:15:34, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit David Carlisle <(E-Mail Removed)>:

>> > And the final question :
>> > How to copy all the attributes without 'id' and 'number' ones?

>> <xsl:copy-of select="@*[not(self::id or self::number)]"/>
>>

>
> You have to use name()!='id' rather than not(self::id) as self::id
> selects elements not attributes.


If that is true - and I do not doubt that you're right - then I've been posting non-working code for months
Yet another bug in my XSLT processor (it select attributes and element in the 'self' axis), I should really consider moving to another...

Thanks for pointing it out.

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Gaudiam omnibus traderat W3C, nec vana fides
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT: how to get either specific attributes or all elements under a parent element hisachu XML 0 09-01-2010 05:40 PM
copying all but one type of Nodes in XSLT Wizfrog XML 5 07-14-2007 09:16 PM
Parse reserved attributes as normal attributes Max XML 1 09-22-2006 12:04 PM
XSLT: preserving an element with all its attributes Martin Plantec XML 3 10-28-2005 03:35 PM
Copying attributes red Python 7 07-24-2005 01:12 AM



Advertisments