Loading ...
Sorry, an error occurred while loading the content.

Comparing and choosing (formally Finding broken links)

Expand Messages
  • Nicola Harlow
    Hi, I m trying to find broken glossary items in my XML documents. Basically the XSL encounters a tag called glossaryytt, goes off to the glossary and recovers
    Message 1 of 1 , Mar 14, 2005
    • 0 Attachment
      Hi,



      I'm trying to find broken glossary items in my XML documents.

      Basically the XSL encounters a tag called glossaryytt, goes off to the
      glossary and recovers the relevant information.

      If there is not glossary item to match it does nothing at the moment,
      which doesn't help me.

      What I want it to do, is try to find the glossary item, and if it can't,
      return a dead link which will show up as an error in the PDF compile.

      But I don't know how to set the <xsl:when> to do this.



      Does any one have any ideas? The alternative is to check them all by
      hand, at the moment that stands at 118 items!



      So far I have:



      <!-- -->

      <xsl:template match="glossarytt">

      <xsl:for-each select="key('glossaryitems-by-name', @name)">

      <xsl:variable name="href">

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

      </xsl:variable>

      <!-- find the glossary item to match this link -->

      <xsl:variable name="name" select="//glossaryitem[.=$href]"/>

      <fo:inline text-decoration="underline" color="green"
      font-weight="bold">

      <fo:basic-link>

      <xsl:choose>

      <xsl:when
      test="glossarytt/name=//glossaryitem/name">

      <xsl:attribute name="internal-destination">

      <xsl:value-of select="$href"/>

      </xsl:attribute>

      <xsl:value-of select="term"/>

      </xsl:when>

      <xsl:when
      test="count(//*[glossaryitem/name=$href])=0">

      <xsl:attribute
      name="internal-destination">Broken Glossaytt</xsl:attribute>

      </xsl:when>

      </xsl:choose>

      </fo:basic-link>

      </fo:inline>

      </xsl:for-each>

      </xsl:template>

      <!-- -->



      And I know. It's useless :)



      Nicola



      Nicola Harlow
      Technical Author
      The Program Management Group plc
      tel: +44 (0) 1937 547 171
      direct: +44 (0) 1937 547 165
      fax: +44 (0) 1937 547 154
      mail: nicola.harlow@...
      web: http://www.pm-group.com

      ________________________________

      From: Nicola Harlow [mailto:nicola.harlow@...]
      Sent: 14 March 2005 09:27
      To: XSL-FO@yahoogroups.com
      Subject: RE: [XSL-FO] Finding broken links



      "Searching the PDf for "glossarytt" will help you finding the
      problematic
      cases."





      Thanks for the suggestion, but if the XSL can't find the correct
      glossary item it outputs nothing, just leaves a little gap, which
      doesn't help the flow of the sentance much! I can look and check them
      all individually, but we're talking about a 100 page document (now!)
      with hundreds of entries. If I can find an automatic way of doing it,
      that would help.



      I have experimented with <if> statements, but they don't do anything at
      all, and I don't know why (yes I do, I can't write XSL ;)



      Any further suggestions, anyone????? This is my hacked version that
      fails...





      <!-- / / / / / / Glossary tooltips/ / / / / / / / / / / / / / / / / /
      / / / / -->

      <!--Link directly to an existing glossary -->

      <xsl:key name="glossaryitems-by-name" match="glossaryitem"
      use="@name"/>

      <!-- -->

      <xsl:template match="glossarytt">

      <xsl:for-each select="key('glossaryitems-by-name', @name)">

      <xsl:variable name="href">

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

      </xsl:variable>

      <!-- find the glossary item to match this link -->

      <xsl:variable name="name" select="//glossaryitem[.=$href]"/>

      <fo:inline text-decoration="underline" color="green"
      font-weight="bold">



      <fo:basic-link>

      <xsl:if
      test="count(//*[glossaryitem/name=$href])=0">

      <xsl:attribute name="internal-destination">
      broken</xsl:attribute>

      </xsl:if>

      <xsl:attribute name="internal-destination">

      <xsl:value-of select="$href"/>

      </xsl:attribute>

      <xsl:value-of select="term"/>

      </fo:basic-link>

      </fo:inline>

      </xsl:for-each>

      </xsl:template>

      <!-- -->



      Thanks :)



      Nicola

      Nicola Harlow
      Technical Author
      The Program Management Group plc
      tel: +44 (0) 1937 547 171
      direct: +44 (0) 1937 547 165
      fax: +44 (0) 1937 547 154
      mail: nicola.harlow@...
      web: http://www.pm-group.com

      ________________________________

      From: J.Pietschmann [mailto:j3322ptm@...]
      Sent: 11 March 2005 20:22
      To: XSL-FO@yahoogroups.com
      Subject: Re: [XSL-FO] Finding broken links



      Nicola Harlow wrote:
      > I'm trying to get XSL:FO to highlight missing information in my PDF
      > output.

      Try something like
      <xsl:template match="glossarytt">
      <xsl:variable name="items" select="key('glossaryitems-by-name',
      @name)"/>
      <xsl:choose>
      <xsl:when test="$items">
      <xsl:for-each select="$items">
      <xsl:variable name="href" select="@name"/>
      <fo:inline text-decoration="underline" color="green"
      font-weight="bold">
      <fo:basic-link internal-destination="{$href}">
      <xsl:value-of select="term"/>
      </fo:basic-link>
      </fo:inline>
      </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
      <fo:inline color="red">Broken glossarytt: <xsl:value-of
      select="@name"/></fo:inline>
      </xsl:otherwise>
      <xsl:choose>
      </xsl:template>

      Searching the PDf for "glossarytt" will help you finding the problematic
      cases.

      J.Pietschmann




      Yahoo! Groups Sponsor

      ADVERTISEMENT
      click here
      <http://us.ard.yahoo.com/SIG=129748alb/M=298184.6018725.7038619.3001176/
      D=groups/S=1705016061:HM/EXP=1110658934/A=2593423/R=0/SIG=11el9gslf/*htt
      p:/www.netflix.com/Default?mqso=60190075>


      <http://us.adserver.yahoo.com/l?M=298184.6018725.7038619.3001176/D=group
      s/S=:HM/A=2593423/rand=130726529>



      ________________________________

      Yahoo! Groups Links

      * To visit your group on the web, go to:
      http://groups.yahoo.com/group/XSL-FO/

      * To unsubscribe from this group, send an email to:
      XSL-FO-unsubscribe@yahoogroups.com
      <mailto:XSL-FO-unsubscribe@yahoogroups.com?subject=Unsubscribe>

      * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      Service <http://docs.yahoo.com/info/terms/> .



      [Non-text portions of this message have been removed]





      Yahoo! Groups Sponsor

      ADVERTISEMENT
      click here
      <http://us.ard.yahoo.com/SIG=129bi2vp0/M=298184.6018725.7038619.3001176/
      D=groups/S=1705016061:HM/EXP=1110878615/A=2593423/R=0/SIG=11el9gslf/*htt
      p:/www.netflix.com/Default?mqso=60190075>


      <http://us.adserver.yahoo.com/l?M=298184.6018725.7038619.3001176/D=group
      s/S=:HM/A=2593423/rand=406680361>



      ________________________________

      Yahoo! Groups Links

      * To visit your group on the web, go to:
      http://groups.yahoo.com/group/XSL-FO/

      * To unsubscribe from this group, send an email to:
      XSL-FO-unsubscribe@yahoogroups.com
      <mailto:XSL-FO-unsubscribe@yahoogroups.com?subject=Unsubscribe>

      * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      Service <http://docs.yahoo.com/info/terms/> .



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.