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

Finding broken links

Expand Messages
  • Nicola Harlow
    Hi, I m trying to get XSL:FO to highlight missing information in my PDF output. I create glossary entries which I then pick up and use elsewhere in the
    Message 1 of 6 , Mar 11 3:43 AM
    • 0 Attachment
      Hi,



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



      I create 'glossary' entries which I then pick up and use elsewhere in
      the document.



      The problem is that if I don't enter the entries correctly, I have no
      way of knowing if they are wrong, the XSL simply skips that bit and
      enters nothing. In a document of about 500 pages it's not easy to find
      words that are missing, I need a way to highlight the gaps.



      Basically I add a tag like this: <glossarytt name="G_Administrator"
      width="200"/>



      And it goes off, finds the glossary term name and creates a link:



      <!-- -->

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

      <!-- -->



      If it can't find the correct glossaryitem, I want it to flag this up to
      me. I can detect 'broken' internal destinations easily as when I
      generate the PDF I get [warnings], so if it could create a broken link,
      that would help.



      I've tried <xsl:if> but I'm getting no where. Any suggestions????



      Ta,



      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





      [Non-text portions of this message have been removed]
    • J.Pietschmann
      ... Try something like
      Message 2 of 6 , Mar 11 12:22 PM
      • 0 Attachment
        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
      • Nicola Harlow
        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
        Message 3 of 6 , Mar 14 1:26 AM
        • 0 Attachment
          "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]
        • J.Pietschmann
          ... Did you try the code I provided in my message? ... Get a good book about XSLT, read the XSLT FAQ, and join the XSL list
          Message 4 of 6 , Mar 22 11:14 AM
          • 0 Attachment
            Nicola Harlow wrote:
            > 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.
            >

            Did you try the code I provided in my message?

            >
            > 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 ;)

            Get a good book about XSLT, read the XSLT FAQ, and join the XSL list
            http://www.mulberrytech.com/xsl/xsl-list/

            J.Pietschmann
          • Nicola Harlow
            HI, Apologies, I didn t notice you d given me a code sample. I will try it when I get a chance to :) I have got several XSLT books, and am a member of several
            Message 5 of 6 , Mar 24 2:20 AM
            • 0 Attachment
              HI,



              Apologies, I didn't notice you'd given me a code sample. I will try it
              when I get a chance to :)



              I have got several XSLT books, and am a member of several lists, but
              unfortunately I do not have a development background which makes it
              harder to know the questions to ask, let alone what to do! My experience
              is in basic HTML, so is a tad inadequate for the full job of XML :)



              Thanks for your help,



              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: 22 March 2005 19:14
              To: XSL-FO@yahoogroups.com
              Subject: Re: [XSL-FO] Finding broken links



              Nicola Harlow wrote:
              > 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.
              >

              Did you try the code I provided in my message?

              >
              > 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 ;)

              Get a good book about XSLT, read the XSLT FAQ, and join the XSL list
              http://www.mulberrytech.com/xsl/xsl-list/

              J.Pietschmann




              Yahoo! Groups Sponsor

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


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



              ________________________________

              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]
            • Nicola Harlow
              Hi again, Just tried the code and it worked a treat, thank you! I tweaked it a tad so that it now creates a broken link this means that I am now alerted to
              Message 6 of 6 , Mar 24 5:31 AM
              • 0 Attachment
                Hi again,



                Just tried the code and it worked a treat, thank you!



                I tweaked it a tad so that it now creates a broken 'link' this means
                that I am now alerted to any broken glossary items when I create a PDF.
                This will be a huge timesaver for me, and gives me a template for
                further development!



                And I swear from now on to read replies a bit more carefully :)



                <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:basic-link
                internal-destination="BrokenGlossaryTT">

                <fo:inline color="red">Broken glossarytt:
                <xsl:value-of

                select="@name"/></fo:inline></fo:basic-link>

                </xsl:otherwise>

                </xsl:choose>

                </xsl:template>



                Thanks again,



                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: 22 March 2005 19:14
                To: XSL-FO@yahoogroups.com
                Subject: Re: [XSL-FO] Finding broken links



                Nicola Harlow wrote:
                > 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.
                >

                Did you try the code I provided in my message?

                >
                > 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 ;)

                Get a good book about XSLT, read the XSLT FAQ, and join the XSL list
                http://www.mulberrytech.com/xsl/xsl-list/

                J.Pietschmann




                Yahoo! Groups Sponsor

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


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



                ________________________________

                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=129lsb70e/M=298184.6191685.7192823.3001176/
                D=groups/S=1705016061:HM/EXP=1111745788/A=2593423/R=0/SIG=11el9gslf/*htt
                p:/www.netflix.com/Default?mqso=60190075>


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



                ________________________________

                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.