www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  WebPublisher PRO    XSL problem when displaying search results
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Posted
Hi all,

I'm still new to XSLT, and was hoping someone could help me out with something.

I want to apply formatting to my search results, alla the following:

Author name. Title of article. (Original article title if it was originally in a foreign language). Title of journal volume_number (issue_number) : page_numbers. Date.

Now, not all articles in our textbase have issue numbers depending on the journal, or are in a language other than english. I know that XSL will skip over any blank elements, but I want to apply some extra formatting to the data in the XSL file, as the foreign language articles and the issue number are not catalogued with brackets and spaces between each entry. When we used to use the DBTW form designer, we would format the box as above, by putting the opening bracket, then the field ID, and then a closed bracket; in the search results, it would display it properly and would skip any instances where there was an empty field. In order to achieve the same effect by using XML/XSL, I have tried the following:

<xsl:choose>
  <xsl:when test="inm:ORIGINAL-TITLE">
    <xsl:text>(</xsl:text><xsl:value-of select="inm:ORIGINAL-TITLE"/><xsl:text>) </xsl:text>
  </xsl:when>
  <xsl:otherwise>
    <xsl:text></xsl:text>
  </xsl:otherwise>
</xsl:choose>


and

<xsl:if test="inm:ORIGINAL-TITLE">
  <xsl:text>(</xsl:text><xsl:value-of select="inm:ORIGINAL-TITLE"/><xsl:text>) </xsl:text>
</xsl:if>


In either case, in the middle of the result there will be a pair of brackets () without any text in them regardless of whether the record has any data in the "inm:ORIGINAL-TITLE" field. I thought that the way I had programmed it meant that it was simply calling the field contents regardless of whether it was empty, so I tried the following to specify that only when there is any content in the "inm:ORIGINAL-TITLE" field that it should display the result, as per the following:

<xsl:choose>
  <xsl:when test="inm:ORIGINAL-TITLE='*'">
    <xsl:text>(</xsl:text><xsl:value-of select="inm:ORIGINAL-TITLE"/><xsl:text>) </xsl:text>
  </xsl:when>
  <xsl:otherwise>
    <xsl:text></xsl:text>
  </xsl:otherwise>
</xsl:choose>


and

<xsl:if test="inm:ORIGINAL-TITLE='*'">
  <xsl:text>(</xsl:text><xsl:value-of select="inm:ORIGINAL-TITLE"/><xsl:text>) </xsl:text>
</xsl:if>


When I tried this, the field was never displayed even if there were contents in there, so I'm assuming I've mangled the ='*' syntax in the expression. The only other option I was thinking is if I can specify that if an element is blank, ignore it, otherwise apply the following, like so:

<xsl:choose>
  <xsl:when test="inm:ORIGINAL-TITLE=[b]blank[/b]">
    <xsl:text></xsl:text>
  </xsl:when>
  <xsl:otherwise>
    <xsl:text>(</xsl:text><xsl:value-of select="inm:ORIGINAL-TITLE"/><xsl:text>) </xsl:text>
  </xsl:otherwise>
</xsl:choose>


However, I don't know the syntax to specify in the expression for a blank element.

If anyone could help out, it would be very much appreciated! I've been trying to research and determine what I'm doing wrong for the last could of days, and this is really starting to frustrate me! Like I said, I'm new to XML and XSL, and any help would be appreciated. I've had success using xsl:if and xsl:choose functions elsewhere in the document, it's just here that I'm having problems.

Thanks again!

- Sean

This message has been edited. Last edited by: Sean B,
 
Posts: 8 | Location: Adelaide, Australia | Registered: Wed September 26 2007Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Just made an edit to the above document, as I made a typo when I wrote out the post by closing off the xsl:if tag incorrectly; note that I didn't make the same mistake when coding up my xsl, I only fudged it in the above post :P

So, does anyone have any ideas on what I might be doing incorrectly or any suggestions to apply selective/conditional formatting to XML elements providing there is any data present? Any help would be appreciated.

Cheers,

- Sean
 
Posts: 8 | Location: Adelaide, Australia | Registered: Wed September 26 2007Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  WebPublisher PRO    XSL problem when displaying search results