space and tab(removal) in xsl:attribute

Here should go questions about transforming XML with XSLT and FOP.
tasos
Posts: 3
Joined: Thu Apr 30, 2009 2:46 pm

space and tab(removal) in xsl:attribute

Post by tasos »

Hello people and nice to meet you.
Using visual studio i have a major problem editing xsl files.
When using:
<xsl:attribute name='onclick'>
space character space character space character alert('foo'); tab character tab character
</xsl:attribute>
The space or tabs(of course in visual studio i can convert tabs to spaces but it doesn't help) are included in the event.So this creates problems in id(for example) elements.
Is it possible by using the oxygen editor to remove spaces or tabs?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: space and tab(removal) in xsl:attribute

Post by sorin_ristache »

Hello,

How are the spaces inserted? Can you avoid inserting the spaces when the XSL file is created?

If you do ot want to remove the spaces manually from the XSL file you can create other XSL file that processes this XSL file and removes the spaces that were inserted between alert('foo'); and </xsl:attribute>.


Regards,
Sorin
tasos
Posts: 3
Joined: Thu Apr 30, 2009 2:46 pm

Re: space and tab(removal) in xsl:attribute

Post by tasos »

Hey,thanks for replying.
Take a look at
http://pastebin.com/m7ac909f5
When 1=1 is followed by spaces alert('a') and again spaces.
I can avoid them but it is painful.
For example suppose that someone has formatting enabled on visual studio.
The spaces are created because of formatting.
For example xmlspy has integration with visual studio.
It has an option of removing formatting(that visual studio performs) on any element you select(for example xsl:attribute).
This is what i'm talking about.
I just want to use oxygenxml as my main xsl/xml editor but with the previous ability.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: space and tab(removal) in xsl:attribute

Post by sorin_ristache »

Hello,

I don't know how the formatting works in Visual Studio but you can create the attribute with code like the following for avoiding the spaces:

Code: Select all

  <xsl:variable name="value">

alert('foo');

</xsl:variable>

<xsl:attribute name='onclick'>
<xsl:value-of select="normalize-space($value)"/>
</xsl:attribute>

Regards,
Sorin
Post Reply