Jump to content

Selectively disabling indenting during XSLT?


Guest Dorkmaster Flek

Recommended Posts

Guest Dorkmaster Flek

I'm trying to transform a list of links in XML data into a series of <a> tags with <img> tags in between them as the links. However, my transform engine inserts line breaks after each <a> tag. This is causing a problem with our CSS definitions because we want the images to have no space between them, but the browser is interpreting this newline as a space, which causes our perfectly aligned images to be thrown off. So far, the only solution I've come up with is putting indent="no" in the <xsl:output> tag at the top of the transform, but that makes the whole page source one big line and is very ugly. Is there a way to selectively disable the indenting for the particular template that is doing the link transforms?

Link to comment
Share on other sites

Hi there,I did the same thing and it works perefctly alright without blanks. But I have packed all that in a table structure and have the pics i a row in a cell. Maybe that helps...

<td><xsl:variable name="link"><xsl:for-each select="File_Filename0"/></xsl:variable><a href="{$link}"><img border="0" align="middle" src="First.bmp"/></a><a href="{$link}"><img border="0" align="middle" src="Second.bmp"/></a><a href="{$link}"><img border="0" align="middle" src="Third.bmp"/></a></td>

Link to comment
Share on other sites

Practically speaking, an end-user is not interested in the looks of the source code. Infact, (s)he benefits from the code not being indented scince it slightly reduces download time.For developers... that's what the XSLT file is for, right? If it's for the designers.... uh... OK... you got me.I had the opposite issue, where I needed to selectively add an extra space between two XSLT elements, that was otherwise not created, due to white space stripping rules. I solved the issue by adding xml:space="preserve" to the parent of those two elements.I think adding xml:space="preserve" to elements might also kill indention. That is because this attributes leaves the space inside the targeted element alone. Note that you must use xml:space inside the XSLT file for this particular case.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...