RE: [xsl] DTD and Collection

Subject: RE: [xsl] DTD and Collection
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 28 Aug 2009 09:36:03 +0100
Your DTD appears to be one of those ghastly ones that attaches a default
namespace to some of the elements in your XML. There are DTD designers who
think this is clever, and there are others who do it deliberately because
they like to drive XSLT programmers insane. If you find the culprit, report
them to their professional standards body and have them expelled.

Meanwhile, look into the DTD, look for a declaration of the xmlns attribute
with a default value, and use that namespace as the value of
xpath-default-namespace in your stylesheet.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

 

> -----Original Message-----
> From: Ganesh Babu N [mailto:nbabuganesh@xxxxxxxxx] 
> Sent: 28 August 2009 07:13
> To: XSL
> Subject: [xsl] DTD and Collection
> 
> Dear all,
> 
> I am having 10 XML files in a directory called 
> "D:/cover/mambio" as follows:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE book-review PUBLIC "-//ES//DTD journal article DTD 
> version 5.1.0//EN//XML" "art510.dtd" []> <book-review 
> docsubtype="brv" xml:lang='en'>
> 	<item-info>
> 		<jid>MAMBIO</jid>
> 		<aid>40200</aid>
> 		<ce:pii>S1616-5047(07)00201-7</ce:pii>
> 		<ce:doi>10.1016/j.mambio.2007.11.013</ce:doi>
> 		<ce:copyright type="society" 
> year="2007">Deutsche Gesellschaft f&uuml;r 
> S&auml;ugetierkunde</ce:copyright>
> 	</item-info>
> </book-review>
> 
> I am using collection function to display <aid> value from each file.
> (This is simple step of a bigger project)
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:ce="http://www.elsevier.com/xml/common/dtd";	
> xmlns:sb="http://www.elsevier.com/xml/common/struct-bib/dtd";	
> xmlns:tb="http://www.elsevier.com/xml/common/table/dtd";	
> xmlns:mml="http://www.w3.org/1998/Math/MathML";	
> xmlns:xlink="http://www.w3.org/1999/xlink";
> xmlns="http://www.elsevier.com/xml/ja/dtd";
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
> exclude-result-prefixes="ce sb tb xlink mml saxon xs f"	
> version="2.0">
> 	<xsl:output method="xml"/>
> 	<xsl:template name="main">
> 	     <xsl:for-each
> select="collection('file:///D:/cover/MAMBIO?select=*.xml;recur
> se=yes;on-error=warning')">
> 	           <xsl:value-of select="document-uri(.)"/>
>                    <xsl:value-of 
> select="./book-review/item-info/aid"/>
> 	      </xsl:for-each>
> 	</xsl:template>
> </xsl:stylesheet>
> 
> i am using catalogs to resolve the DTD.
> 
> Here is the command i am using for processing.
> 
> java -cp "C:\Program Files\java\saxon9.jar;C:\Program 
> Files\java\xercesImpl.jar;C:\Program
> Files\java\xml-apis.jar;C:\Program Files\java\resolver.jar"
> -Dxml.catalog.files="E:\programs\samples-macparser\cat1.xml"
> 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 -it:main -xsl:test.xsl
> 
> I am getting only files names displayed. I am not getting the 
> <aid> values. Even after adding the ce namespace also only 
> filename is coming. When i remove DOCTYPE and add namespace 
> then i am getting <aid> value.
> 
> Please suggest how to get <aid> with DOCTYPE.
> 
> Regards,
> Ganesh

Current Thread