[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Processing Links With Relative or Absolute Paths

Subject: Processing Links With Relative or Absolute Paths
From: Robert Siebens <telehodown@xxxxxxxxx>
Date: Wed, 7 Oct 2009 10:52:12 -0700 (PDT)
 Processing Links With Relative or Absolute Paths
Ibm new to XSLT and XSL:FO and apologize for asking such a basic question in
this list. I looked around on the XSL archive
(http://www.biglist..com/lists/xsl-list/archives/), Dave Pawson's site and
elsewhere  and wasn't able to find what I needed.

I am confused about how to handle links containing paths to the file system
such as the relative <a href="../system/companies/logic_preferences.htm"> or
the absolute <a
href="c:\project_files\system\companies\logic_preferences.htm">.  I am
combining many XML files into a PDF (through FOP-0.95). Ibve found code
samples that help me process other types of links such as internal anchors
(like <a href="#My_Big_Anchor">),as well as to process external links
containing URIs. Each of these makes use of a source and target. Where I'm
stumped is how to create a source and target when the "href" points to a file
in the file system (either relative or absolute paths). Perhaps that's not the
technique to handle this?

When I include the snippet below in my XSL stylesheet, it treats the "href"
attributes containing directory paths as external links and creates a link in
my PDF to the actual file outside the document. What's the XSLT trick for
handling this third type of link that should point inside the document?

Here is an example of what I'm doing so far:

---------------------------------------------------
CODE (for file with two types of anchor tags)
---------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<test>

<p>This file has an anchor tag pointing to the <a
href="../system/companies/logic_preferences.htm">file</a> below. But when FOP
combines my XML files, Ibm not sure how to set up a link from one file to
the other via the relative path. Even if I change this to an absolute path, it
points to the XML file in the file system--not to the location of the content
in the combined PDF.</p>

<p>This file also has an internal anchor to another <a
href=#My_Same_Page_Anchor>item</a> on the same page.</p>

<p>Here is the <a name=bMy_Same_Page_Anchorb>target</a> of the anchor from
the same page. This type of link works without a hitch in my FOP.</p>

</test>

---------------------------------------------------
CODE (for file that is the target of the anchor tag in the file above)
---------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>

<test>
<p>This file is the target of the anchor tag in the file above. </p>
</test>

---------------------------------------------------
CODE (Stylesheet code to processes internal links flagged by the b#b as
well as external links using URIs:)
---------------------------------------------------
<xsl:template match="a">
  <xsl:choose>
    <xsl:when test="@name">
      <xsl:if test="not(name(following-sibling::*[1]) = 'h1')">
        <fo:block line-height="0" space-after="0pt"
          font-size="0pt" id="{@name}"/>
      </xsl:if>
    </xsl:when>
    <xsl:when test="@href">
      <fo:basic-link color="blue">
        <xsl:choose>
          <xsl:when test="starts-with(@href, '#')">
            <xsl:attribute name="internal-destination">
              <xsl:value-of select="substring(@href, 2)"/>
            </xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute name="external-destination">
              <xsl:value-of select="@href"/>
            </xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:apply-templates select="*|text()"/>
      </fo:basic-link>
      <xsl:if test="starts-with(@href, '#')">
        <xsl:text> on page  </xsl:text>
        <fo:page-number-citation ref-id="{substring(@href, 2)}"/>
      </xsl:if>
    </xsl:when>
  </xsl:choose>
</xsl:template>

What should I add to process this third type of link that contains a relative
or absolute path?

Regards,

Rob

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.