Jump to content

Using inline when seperating data and format


omegared

Recommended Posts

When applying inline styles such as bold. Italic or underline this is accomplished by using something like <fo:block font="12pt Arial"> hello <fo:inline font-weight="bold" color="red">world</fo:inline> </fo:block>.However in this example the data and format is not separated. I am using <xsl:value-of select=”.”> (where .=”hello world”). If I used <fo:inline font-weight="bold" color="red"><xsl:value-of select=”.”></fo:inline> it would change both 'hello' and 'world'. How do you specify you want to change world only when you have seperated content and formatting?Many thanks

Link to comment
Share on other sites

I think it could be done with the substring() function, but it's kind'a uncomfortable. You should make it a habbit to mark every piece which should be handled separately in any manner.Just for the sake of demonstration:

<xsl:variable name="HW" select="."/><fo:block font="12pt Arial"><xsl:value-of select="substring($HW, 0, 5)"/><fo:inline font-weight="bold" color="red"><xsl:value-of select="substring($HW, 6)"/></fo:inline> </fo:block>

The first argument is the string, which we get from the variable, the second one points from where to start extracting the string. The third optional argument shows how many characters should be extracted. If omitted, the whole string from the starting position to the end of the element is extracted.

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...