473,327 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

copying all attributes in XSLT

R
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
Jul 20 '05 #1
4 1231
Tempore 18:37:57, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit R <ru******@poczta.onet.pl>:
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
Jul 20 '05 #2


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/
Jul 20 '05 #3

"Joris Gillis" <ro**@pandora.be> writes:
Tempore 18:37:57, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit R <ru******@poczta.onet.pl>:
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
Jul 20 '05 #4
Tempore 23:15:34, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit David Carlisle <da****@nag.co.uk>:
> 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
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wolfgang | last post by:
XSLT transformations by default seem to pass name space attributes into the root element of their output (example below). QUESTION: Is it possible to control this, i.e. not genrating a name...
9
by: Soren Kuula | last post by:
Hi, I just can't find namespaces of attributes stated clearly enough in the XML namespace spec. But .. I hear rumors that attributes, unless qualified otherwise, default to the namespace of the...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
2
by: JJ | last post by:
I need to basically copy an entire XML document to another XML document. The first needs to be an exact copy of the second, and I need to do it a node at a time as I am omitting certain nodes...
1
by: Foxpointe | last post by:
Given some arbitrary XHTML, I'd like to obtain a 'simplified' XHTML result which strips out a large subset of standard elements and attributes - but not all. The main things I would like to...
6
by: Jakub.Bednarczuk | last post by:
Hallo everybody I have the problem with getting attributes values and also attributes names. I am reading an xml file with DOM. Lets see an example: file I read <root> <Def></Def>...
5
by: asciz | last post by:
Hi I'm having a problem with an XML file, most likely because of my lack of understanding of XML schemas I have the following XML file: <?xml version="1.0" encoding="ISO-8859-1"?>...
5
by: mahesh.nimbalkar | last post by:
When I transform XML, XSLT automatically adds extra attributes to the node which are declared in DTD (default DTD attributes) . I just want XSLT not to add these extra default attributes from DTD....
12
by: blackirish | last post by:
Hi all, I am trying to merge 2 XML files that first of all i need to compare nodes of both files according to 2 attributes in the nodes. If those 3 attributes are equal, i need to replace the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.