This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: XSL manipulating two XMLs
- From: "Najmi, Jamal" <Jamal dot Najmi at Artesia dot com>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 1 May 2002 19:57:56 -0400
- Subject: RE: [xsl] XSL manipulating two XMLs
- Reply-to: xsl-list at lists dot mulberrytech dot com
Yes, my two XML documents and XSL file are in the same directory.
I tried the '/' but it did not work. I think my problem comes even before
that, when the document is read by the transformer. Transformer is looking
in the processor's directory.
I have tried implementing the URIResolver and Source interfaces, but I am
still geting errors.
Here is the listing of my implementation classes:
******************************************
import javax.xml.transform.URIResolver;
import javax.xml.transform.TransformerException ;
import javax.xml.transform.Source;
public class URIResolverImpl implements URIResolver {
private final static String FILE_SEPARATOR_PROPERTY =
System.getProperty("file.separator") ;
private String _workingDirPath = null ;
public URIResolverImpl(String workingDirpath) {
_workingDirPath = workingDirpath ;
}
public Source resolve(String href, String base) throws
TransformerException {
href = _workingDirPath + FILE_SEPARATOR_PROPERTY + href ;
System.out.println("href in URIResolver: " + href) ;
Source source = new SourceImpl(href) ;
return source ;
}
}
*******************************
and
import javax.xml.transform.Source;
public class SourceImpl implements Source {
private final static String FILE_SEPARATOR_PROPERTY =
System.getProperty("file.separator") ;
private String _systemId = null ;
public SourceImpl(String systemId) {
_systemId = systemId ;
}
public void setSystemId(String systemId) {
System.out.println("System id in set" + systemId) ;
// ignore it
}
public String getSystemId() {
System.out.println("system id in get: " + _systemId ) ;
return _systemId ;
}
}
***************************************
Now here is what getSystemId() returned and what got set in the URIResolver
when application ran. This is from the standard output of tomcat. Does
this output give any idea if I am setting something wrong in the
implementation classes?
href in URIResolver:
/u01/artesia/teamsdne/jamalsandbox/workingdir/1020296490674/content.xml
system id in get:
/u01/artesia/teamsdne/jamalsandbox/workingdir/1020296490674/content.xml
system id in get:
/u01/artesia/teamsdne/jamalsandbox/workingdir/1020296490674/content.xml
Here is the error meesage:
SystemId Unknown; Line 50; Column 35; Can not load requested doc: Not
supported: com.artesia.cus
t.discovery.web.common.SourceImpl@437f31
Will really appreciate any help!!!
Jamal
-----Original Message-----
From: J.Pietschmann [mailto:j3322ptm@yahoo.de]
Sent: Wednesday, May 01, 2002 11:51 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] XSL manipulating two XMLs
Najmi, Jamal wrote:
> I am using xalan for transformation in tomcat servlet engine. I copy the
> two XML files and the XSL to a directory created on the fly, import one
XML
> file into XSL and pass the other one via the Xalan API. Every thing shoud
> work except that XSL transformer starts looking for the imported XML file
> not in the currtent directory but in the TOMCAT_HOME/bin directory!!! I
> tried putting ./ infront of the imported file name but no use.
>
> Hoe can I make the transformer look into the current directory for the
> included file:
It seems it actually looked into the current working directory
for the process.
> Here is how I am importing the XML document:
>
> <xsl:variable name = "contentXml" select ="document('content.xml')"/>
I'm unsure what you situation you acutally have. If both
the XML file passed to the transformer object and the file
referenced by the document() function are in the same directory,
try:
<xsl:variable name = "contentXml" select ="document('content.xml',/)"/>
^^
No quotes arount the slash, it denotes the root node of
the XML document you passed to the transformer object.
BTW you are supposed to trim unnecessary "original messages"
from time to time.
J.Pietschmann
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list