Subject: RE: [xsl] Procesing XHTML files with DOCTYPE statements From: "Huditsch, Roman \(LNG-VIE\)" <Roman.Huditsch@xxxxxxxxxxxxx> Date: Tue, 11 Jul 2006 08:09:21 +0200 |
Hi, Using an XML catalog[1] should help you resolving this issue. It can be used to locate an alternate URI reference (eg. on your local hard disk) for a DTD. Take a look at [2] for further information on how to use catalog files. CatalogManager.properties: catalogs=catalog.xml relative-catalogs=false static-catalog=yes catalog-class-name=org.apache.xml.resolver.Resolver verbosity=0 XML catalog: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public"> <public publicId="-//W3C//DTD HTML 4.01 Transitional//EN" uri="file:///C:/DTD/xhtml/xhtml1-transitional.dtd"/> </catalog> Run Saxon from cmd line: java net.sf.saxon.Transform -x org.apache.xml.resolver.tools.ResolvingXMLReader -y org.apache.xml.resolver.tools.ResolvingXMLReader -r org.apache.xml.resolver.tools.CatalogResolver -o output.xhtml input.xhtml/ stylesheet.xslt Hope this helps. best regards, Roman [1] http://www.oasis-open.org/committees/entity/spec.html [2] http://www.sagehill.net/docbookxsl/UseCatalog.html > -----Urspr|ngliche Nachricht----- > Von: dvint@xxxxxxxxx [mailto:dvint@xxxxxxxxx] > Gesendet: Dienstag, 11. Juli 2006 02:03 > An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Betreff: [xsl] Procesing XHTML files with DOCTYPE statements > > This is the first time I've had to process XHTML files with XSLT. I'm > using saxon and getting an error that it can't find the DTD referenced in > the file that I'm processing. File has: > > <!DOCTYPE html > PUBLIC "-//W3//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd"> > > Result is: > > Error on line 4 column 107 of > file:/C:/dev/LanguageDetection/RM0000010ZQ000X.htm > l: > Error reported by XML parser: Cannot read from > http://www.w3.org/tr/xhtml1/DTD > /xhtml1-transitional.dtd > Transformation failed: Run-time errors were reported > > This problem goes away as soon as I delete the DOCTYPE info, but I don't > want to (can't) do this for every file. Is there some way around this > error? Note that the DTD does exist at the URL provided, but the default > setup in Saxon doens't seem to find it. > > This stylesheet is doing basically an identiy transformation with one > change in the body element to insert a new comment. Here is the stylesheet > in case there might be a way to work around this problem: > > <?xml version="1.0" encoding="utf-8"?> > <xsl:stylesheet > version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns="http://www.w3.org/1999/xhtml" > xmlns:t3="http://tms.toyota.com/t3" > > > > <xsl:param name="language" select="'en'" /> > > <xsl:variable name="commentText"> > <xsl:choose> > <xsl:when test="$language='en'"> > text 1 goes here </xsl:when> > <xsl:when test="$language='fr'"> > text 2 goes here > </xsl:when> > <xsl:when test="$language='sp'"> > Text 3 goes here </xsl:when> > <xsl:otherwise>UNRECOGNIZED LANGUAGE SPECIFIED</xsl:otherwise> > </xsl:choose> > </xsl:variable> > > <xsl:output method="html" > omit-xml-declaration="no" > doctype-public="-//W3//DTD XHTML 1.0 Transitional//EN" > doctype-system="http://www.w3.org/tr/xhtml1/DTD/xhtml1- > transitional.dtd" > indent="no"/> > > > <xsl:template match="*"> > <xsl:choose> > <xsl:when test="name(.)='body'"> > <xsl:element name="{name(.)}"> > <xsl:for-each select="@*"> > <xsl:attribute name="{name(.)}" > namespace="{namespace-uri(.)}"><xsl:value-of > select="."/></xsl:attribute> > </xsl:for-each> > <xsl:comment> > <xsl:value-of select="$commentText"/> > </xsl:comment> > <xsl:apply-templates/> > </xsl:element></xsl:when> > <xsl:otherwise> > <xsl:element name="{name(.)}"> > <xsl:for-each select="@*"> > <xsl:attribute name="{name(.)}" > namespace="{namespace-uri(.)}"><xsl:value-of > select="."/></xsl:attribute> > </xsl:for-each> > <xsl:apply-templates/> > </xsl:element> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > <xsl:template match="comment()"> > <xsl:comment><xsl:value-of select="."/></xsl:comment> > </xsl:template> > > </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Procesing XHTML files wit, Mukul Gandhi | Thread | [xsl] Text Wrapping problem with xs, Pankaj Bishnoi |
[xsl] Procesing XHTML files with DO, dvint | Date | Re: [xsl] XML->HTML tables with bla, Mukul Gandhi |
Month |