Jump to content

XSL:FO


lukazar

Recommended Posts

Hello,I'm trying to figure out a way to look through an XML document, find keywords, and then either bold those words, or highlight them. I have very little knowldege with xsl, so I would need quite a bit of help. Does anyone have time time to help me out, or know of a good reference that would aid in trying to accopmlish said task?Thanks,Luke

Link to comment
Share on other sites

It depends on whether this content is a complete element or content of an element. If it's an element (or attribute on that matter) it's easy:

<xsl:param name="searchedElement" /><xsl:template match="*[name()=$searchedElement]"><strong><xsl:apply-templates/></strong></xsl:template><xsl:template match="/"><html><body><xsl:apply-templates/></body></html></xsl:template>

Where the $searchedElement parameter is edited outside the XSLT with a server side scripting language.But if you want to look for a prase inside an element or an attribute, the things get harder. The idea of an XSLT search engine sounds good though, so I'll try looking deeper some time soon.[edit] Here's some XPath expression I "invented" some time ago and just noticed it. I haven't tested it yet, but it might do the trick:

<xsl:value-of select="//*[contains(text(),$SearchString)]" />

[/edit]P.S. In this example I've used XML-to-XHTML example as this is what I'm used to. If you want the results in XSL-FO, just rename the proper elements.

Link to comment
Share on other sites

I'm looking to do it the hard way :) I'll try out your code here in a bit thanks! I have another question for you.I have a tag that looks like so:

<transcription lengo="100" session="1" sessiontype="regular" status="RoughDraft" transtype="floor">....</transcription>

Is it possible to pull out the value of status and show that? Say I create a PDF of the above code, I would like it to say RoughDraft or Complete in the header depending on status...Thanks again

Link to comment
Share on other sites

It depends. If what you're showing is part of the input (XML) then it's simply something like:

<xsl:value-of select="transcription/@status" />

And if it's part of the transformation (XSLT) then you should use this instead:

<xsl:value-of select="document('')//transcription/@status" />

A document() function with an empty string as an argument means that the XSLT will look into itself for the XPath expression after.

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