Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2007, 09:06 AM
Registered User
 
Join Date: Nov 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default unparsed-entity-uri() changes files extension

I am creating an XSL-FO stylesheet to generate a PDF file. I am using the following code to pull my graphics.

<fo:external-graphic>

<xsl:attribute name="src"><xsl:text>url(</xsl:text><xsl:value-of select="unparsed-entity-uri(@gnbr)"/><xsl:text>)</xsl:text></xsl:attribute>

</fo:external-graphic>

This works great on JPEG files. However we use a mixture of tifs and cgm files. It will reference the location of the graphic file but changes the file extension to a .gif therefore I am receiving an error message saying that it cannot open the file. How can I get it to recognize the .tif and .cgm files.

Any help would be greatly appreciated.

Thanks,

Sarah Copley
 
Old November 28th, 2007, 09:10 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I can't tell what is wrong as we can't see your <!ENTITY> elements or the source XML.

For an overview of that function try here: http://www.w3schools.com/xsl/func_unparsedentityuri.asp

/- Sam Judson : Wrox Technical Editor -/
 
Old November 28th, 2007, 09:10 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Sounds rather surprising. What's in your source XML, and what XSLT processor are you using? Please show sample input, stylesheet, and output.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old November 28th, 2007, 09:43 AM
Registered User
 
Join Date: Nov 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using Arbortext 5.2 M020 as my processor. It is an XML editor. We are validating against an XSD Schema.

Here is the sample input:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ipc [
<!ENTITY Deferred SYSTEM "G:\XXXX\Publication Illustrations\Books\Process Guides\jpeg\Deferred.jpg" NDATA jpg>
<!NOTATION jpg SYSTEM "jpg">
<!ENTITY graphic04007a SYSTEM "G:\XXXX\Publication Illustrations\Books\Process Guides\cgm\04007a.cgm" NDATA cgm>
<!NOTATION cgm SYSTEM "cgm">
<!ENTITY e17s03 SYSTEM "G:\XXXX\Publication Illustrations\Books\Process Guides\tif\e17s03.tif" NDATA tif>
<!NOTATION tif SYSTEM "tif">
]>

<figure id="fig1">
<sheet>
<graphic chg="u" gnbr="e17s03"/>
</sheet>
</figure>
<figure id="fig2">
<sheet>
<graphic chg="u" gnbr="graphic04007a"/>
</sheet>
</figure>
<figure id="fig3">
<sheet>
<graphic chg="u" gnbr="Deferred"/>
</sheet>
</figure>

Here is a snippet of my stylesheet:

<xsl:template match="ipc:figure">
        <fo:block-container xsl:use-attribute-sets="text space" span="all" start-indent="0pt" end-indent="0pt">
            <fo:block text-align="center">
                <xsl:for-each select="descendant::ipc:graphic">
                    <fo:external-graphic>
                        <xsl:attribute name="src"><xsl:text>url(</xsl:text><xsl:value-of select="unparsed-entity-uri(@gnbr)"/><xsl:text>)</xsl:text></xsl:attribute>
                    </fo:external-graphic>
                </xsl:for-each>
            </fo:block>
            <fo:block text-align="center">
                        Figure <xsl:number format="1" level="any"/>
            </fo:block>
            <fo:block xsl:use-attribute-sets="text" text-align="center">
                <xsl:value-of select="descendant::ipc:title"/>
            </fo:block>
        </fo:block-container>
    </xsl:template>

My PDF output shows only the jpg graphic. I get an error message for the other 2 graphics that says "The graphics file G:\XXXX\Publication Illustrations\Books\Process Guides\tif\e17s01.gif could not be opened."

and

"The graphics file G:\XXXX\Publication Illustrations\Books\Process Guides\cgm\20100t7a.gif could not be opened."

as you can see it is changing the file extension of the graphic file.
 
Old November 28th, 2007, 10:16 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Take a look at the actual XSL-FO file and see whether the file names are incorrect there, just to verify that it's the XSLT processor that's getting it wrong.

Use system-property('xsl:vendor') somewhere in the stylesheet to see what XSLT processor you are using.

If the XSLT processor really is getting it wrong (not that unlikely, it's a rarely-used function) then send them a bug report.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old November 28th, 2007, 10:32 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your entities end with 04007a.cgm and e17s03.tif

But it's complaining about e17s01.gif and 20100t7a.gif

So it's not just changing the extensions, it's dreaming up the whole filename.

Are you sure you aren't just processing the wrong input file???

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old November 28th, 2007, 10:45 AM
Registered User
 
Join Date: Nov 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I apologize. I changed the graphics after I copied the error message to make sure that there wasn't a problem with the graphics I was using. I just rechecked it and the error message and the graphic entity names are the same it just changes the file extension.

The XSLT Processor that is being used is Saxon 6.5.4 I am researching that now.

Thanks for all your help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
list unparsed-entity-uri() bonekrusher XSLT 6 April 28th, 2008 10:52 AM
xml validation of entity text in txt files reblev XML 1 May 4th, 2006 09:03 AM
FTP download files with same extension otarboy Pro VB 6 0 September 28th, 2004 04:50 AM
Difference between Entity and Entity type arshad mahmood C++ Programming 0 May 8th, 2004 12:34 AM
Referrer and Uri druid2112 General .NET 1 April 20th, 2004 12:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.