]> granicus.if.org Git - docbook-dsssl/commitdiff
An attemp to fix base URIs when profiling is done and document is not in the current...
authorJirka Kosek <jirka@kosek.cz>
Tue, 6 Dec 2005 18:56:52 +0000 (18:56 +0000)
committerJirka Kosek <jirka@kosek.cz>
Tue, 6 Dec 2005 18:56:52 +0000 (18:56 +0000)
xsl/extensions/saxon643/com/nwalsh/saxon/ImageIntrinsics.java
xsl/profiling/profile-mode.xsl
xsl/profiling/profile.xsl

index 2eb069f5425284151d6fb69cee37900afbd6d6cd..9f6b9e4191fa8baa38e87bf64acaf9a19daa85e2 100644 (file)
@@ -57,7 +57,7 @@ public class ImageIntrinsics implements ImageObserver {
 
     URL imageUrl = null;
 
-    if (imageFn.startsWith("http:") || imageFn.startsWith("ftp:")) {
+    if (imageFn.startsWith("http:") || imageFn.startsWith("ftp:") || imageFn.startsWith("file:")) {
        try {
            imageUrl = new URL(imageFn);
        } catch (MalformedURLException mue) {
index b006475a8030ae3d5aa3ed1356e50c73ccf73a0c..25afa06310da0a5ed63d96592fed4ca450a4e9fd 100644 (file)
@@ -1,6 +1,11 @@
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:saxon="http://icl.com/saxon"
+                exclude-result-prefixes="saxon"
                 version="1.0">
 
+<!-- Should be base URI for imagedata and so on fixed? -->
+<xsl:param name="profile.baseuri.fixup" select="true()"/>
+
 <!-- Copy all non-element nodes -->
 <xsl:template match="@*|text()|comment()|processing-instruction()" mode="profile">
   <xsl:copy/>
                 and $revision.ok and $revisionflag.ok and $role.ok and $security.ok
                 and $userlevel.ok and $vendor.ok and $attribute.ok">
     <xsl:copy>
-      <xsl:apply-templates select="@*|node()" mode="profile"/>
+      <xsl:copy-of select="@*"/>
+      <!-- Fix base URI of some elements -->
+      <xsl:if test="$profile.baseuri.fixup and (self::textdata or self::imagedata or self::videodata or self::audiodata or self::inlinegraphic or self::graphic)">
+       <xsl:choose>
+         <xsl:when test="@fileref
+                         and not(contains(@fileref,':'))
+                         and not(starts-with(@fileref,'/'))
+                         and function-available('saxon:systemId')">
+           <xsl:attribute name="xml:base">
+             <xsl:call-template name="systemIdToBaseURI">
+               <xsl:with-param name="systemId">
+                 <xsl:choose>
+                   <!-- file: seems to confuse some processors. -->
+                   <xsl:when test="starts-with(saxon:systemId(), 'file:/') and substring(saxon:systemId(), 7, 2) != '//'">
+                     <xsl:value-of select="concat('file:///', substring-after(saxon:systemId(), 'file:/'))"/>
+                   </xsl:when>
+                   <xsl:when test="starts-with(saxon:systemId(), 'file:')">
+                     <xsl:value-of select="substring-after(saxon:systemId(),
+                                           'file:')"/>
+                   </xsl:when>
+                   <xsl:otherwise>
+                     <xsl:value-of select="saxon:systemId()"/>
+                   </xsl:otherwise>
+                 </xsl:choose>
+               </xsl:with-param>
+             </xsl:call-template>
+           </xsl:attribute>
+         </xsl:when>
+         <xsl:otherwise>
+           <xsl:attribute name="fileref">
+             <xsl:value-of select="@fileref"/>
+           </xsl:attribute>
+         </xsl:otherwise>
+       </xsl:choose>
+
+       <xsl:choose>
+         <xsl:when test="@entityref">
+           <xsl:attribute name="xml:base">
+             <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
+           </xsl:attribute>
+         </xsl:when>
+       </xsl:choose>
+      </xsl:if>
+      <!-- End of base URI fixup -->
+      <xsl:apply-templates select="node()" mode="profile"/>
     </xsl:copy>
   </xsl:if>
 </xsl:template>
index fe1def3554d8cb03dbd0030f1dc6750c2dbf87b7..c4678213ebdd17b7de6886a01a19660a2b1dcd50 100644 (file)
@@ -2,7 +2,13 @@
                 version="1.0">
 
 <!-- Include common profiling stylesheet -->
-<xsl:include href="profile-mode.xsl"/>
+<xsl:import href="profile-mode.xsl"/>
+
+<!-- This file must be included, because profile-mode is using templates from it -->
+<xsl:import href="../common/stripns.xsl"/>
+
+<!-- In the two pass processing there is no need for base URI fixup -->
+<xsl:param name="profile.baseuri.fixup" select="false()"/>
 
 <!-- Generate DocBook instance with correct DOCTYPE -->
 <xsl:output method="xml"