• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xsl

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to highlight a part of text in xsl?

For example

[test]\Have a nice day!

I need to highlight the text within the braces.

Thanks in advance
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I'm sure you know, you can only produce text from an XSL transformation. What would this "highlight" look like in your text output?
 
Shruthi Babu
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to bold the string present inside []
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what would "bold" look like in your output?
 
Shruthi Babu
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For example I need to have some thing like this

[this is a test]\No bold\[Bold txt]
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Div, you don't seem to understand the questions I am asking. You haven't stated your requirements clearly, and when I ask you to clarify, you eventually provided an example that doesn't make sense.

You said your input was this:

[test]\Have a nice day!

And after some questions, you said your desired output was this:

[this is a test]\No bold\[Bold txt]

I don't see any relationship between the two. Can you go back to the beginning and state what your requirements are? Remember that the output of an XSL transformation is simply text, and text by itself doesn't have the concept of "bold". So examples that show boldfaced text don't help.
 
Shruthi Babu
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry if I have confused.

I have an xml which on applying xsl transformations I need to convert into html.

in this case . I need to display in html as bold a part of string whatever appears within []

For example if I have a value as [Test]\aaaaaaa\[Test1]
the HTML should display the [Test] and [Test1] in bold.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, this is a rather difficult question. You want to convert the strings inside the [] characters into some kind of element -- let's keep it simple and suppose you want a <b> element. (Although with modern HTML a <span> element with a CSS style might be preferred, that's just as easy to do.) So you need a template that does this:

1. Find the first [ character (at location n1 in the string)
2. Find the first ] character after that (at location n2 in the string)

If you found them both:
3. Output everything before n1.
4. Output a <b> element whose text is everything between n1 and n2.
5. Call the template recursively, applying it to everything after n2.

If you didn't find them:
3. Output the whole string.

Does that answer your question?
reply
    Bookmark Topic Watch Topic
  • New Topic