Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSLT and embedded tags in text.

 
Heath Lilley
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem with XSLT and I was hoping that you could shed some light on it.
I have a line of text I am referencing in a XML document...

I have been able to find this node via a template AND I can identify the input_text tag as well. What I want to do is replace the input_text tag with a real HTML tag. I am doing this like so...
Find/output the substring before the tag.
Then, output the html input element in place of the tag.
And finally, output the substring after the tag.
The xslt code in question.

The above template defined.

I looked at the xpath functions and I know I can't use the < or > brackets, I tried escaping the brackets < and > but it isn't associating the tag bracets with the codes.
My above code will NOT output any of the substrings. It does output a textbox though.
Am I trying to do something that xslt can't do? Any help would be greatly appreciated.
Thank you for your time.
[ October 22, 2003: Message edited by: Heath Lilley ]
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is that text() will only give you the text value, so that the substring function will not even find the <, however you define it. the value of text() of <xyz/> is empty, I believe.
Maybe you should try to get all the nodes by combining * and text()? and then go thru each node, if a node has a local-name() is input_text, then insert your html code. In this way, you avoid using substring() etc, which is not that reliable in case that you add more nodes in.
Hope it helps.
Tony
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this, it will give you a good idea on how the text() and * work. You can derive from this to get a solution, I hope.

 
Heath Lilley
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the responses. I think I figured it out. I forget where I read it but it seems that text() only returns the text between the start element and the next element NOT the matching ending element.
I have access to changing the xml schema structure so what we did was and another set of element tags to separate the plain text from any embedded tags.

I was oringinally hoping to avoid this but I don't think it was possible.

This allows me to get the text and the input element in the xslt.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic