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 October 20th, 2009, 04:06 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Post Skip DOCTYPE line and prefix for namespace

I'm using xslt 2.0 and saxon 9.I'm processing an xml database from my xslt script. The xml files contains DOCTYPE declaration with a dtd path, where the dtd may not be present. Also the parent element does not contain the namespace declaration for a prefix (ce - ce:display) present in child element (ce:display).Due to these two issues, I get errors. Is there any way to skip the DOCTYPE line and namespace missing error?Any idea is appreciated.
__________________
Rummy
 
Old October 20th, 2009, 04:30 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You can't make the XML parser ignore the DTD entirely, but you can use an EntityResolver to make it use a different "dummy" DTD. The EntityResolver that most people use is the one that comes with Oasis catalogs.

If there's a namespace declaration missing, that's a much tougher problem. It means your document isn't well-formed XML, and Saxon (in fact, XSLT processors generally) can only handle well-formed XML input. There are many benefits in designing your application to use XML as the format for passing data from one component to another, and you lose all these benefits if you try to pass ill-formed XML. So you need to fix the root cause of this problem.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
mrame (October 20th, 2009)
 
Old October 20th, 2009, 05:16 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

I will fix those errors and try the transformation part. Thank you.
__________________
Rummy
 
Old October 22nd, 2009, 01:06 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Post

I tried to create a catalog.xml file which contains the local path for the DTD.
Then I tried to run the below line from DOS command line:
java -cp C:\saxonsa9-1-0-6j\saxon9.jar;resolver.jar -Dxml.catalog.files=catalog.xml net.sf.saxon.Transform -r:org.apache.xml.resolver.tools.CatalogResolver -x:org.apache.xml.resolver.tools.ResolvingXMLReader -y:org.apache.xml.resolver.tools.ResolvingXMLReader -xsl:Lali_graphic.xsl -s:MAIN.xml -o:fig.xml
While doing so I get errorr:
"Exception thrown by URIResover: Malformed URL (E:/42021891/main.xml)(base xsl file name): unknown protocol: e
input xsl:
Same error occurs for both the below lines:
<xsl:variable name="graphics" select="document('E:/42021891/main.xml')//ce:link"/>
<xsl:variable name="stripin" select="document('E:/42021891/main.xml')//mml:math"/>
Input E:/42021891/main.xml:
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE chapter PUBLIC "-//ES//DTD book DTD version 5.3.0//EN//XML" "book530.dtd" [<!ENTITY fx1 SYSTEM "fx1" NDATA IMAGE>]><chapter><info><ce:link locator="fx1"/><ce:link locator="fx3"/><mml:math altimg="si1.gif"><mml:mtext>to check</mml:mtext></mml:math>
Catalog file:
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog " prefer="public">
<group>
<public publicId="-//ES//DTD book DTD version 5.3.0//EN//XML" uri="E:/spiina1004z/Technology/BPR/TechUtilities/DTD/07-Book530/book530.dtd"/>
</group>
</catalog>
Is there anything I'm missing or doing wrong? Any help is appreciated.
__________________
Rummy

Last edited by mrame; October 22nd, 2009 at 01:09 AM..
 
Old October 22nd, 2009, 03:42 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You need to get out of the habit of using Windows filenames in places where the specs require a URI or URL. Some software permits this, but in general, it's against the rules and some software will rightly reject it.

Use file:///e:/my/file/name
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
mrame (October 22nd, 2009)
 
Old October 22nd, 2009, 06:20 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Smile

You are simply great. Many thanks Mike. I will follow the global rule for file path in future. Thanks again.
__________________
Rummy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Exclude a namespace with no prefix bonekrusher XSLT 6 January 23rd, 2009 08:48 AM
Remove namespace prefix from XmlBean ratzko BOOK: Professional Java Development with the Spring Framework 0 August 10th, 2008 01:23 PM
Adding Prefix and Namespace to XML Lerxt XSLT 6 November 8th, 2007 03:14 PM
How a additional prefix in a namespace comes? diang BOOK: ASP.NET Website Programming Problem-Design-Solution 0 July 13th, 2006 10:40 PM
attribute namespace prefix tsmith XSLT 1 August 12th, 2004 06:01 AM





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