Try adding

  dfactory.setNamespaceAware(true);

Before your newDocumentBuilder() call.

HTH,
Gary

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, February 28, 2002 12:49 PM
> To: [EMAIL PROTECTED]
> Subject: TransformerException using DOMSource
> 
> 
> I get an exception:
> 
>       javax.xml.transform.TransformerException: stylesheet requires
> attribute: version
> 
> when I execute xalan with a DOMSource like so:
> 
> public static void main(String[] args){
>     DocumentBuilderFactory dfactory = 
> DocumentBuilderFactory.newInstance();
>     DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
>     Source xsl = new DOMSource(dBuilder.parse(new 
> File(workingDir, "input.xsl")));
>     //Source xsl = new StreamSource(new File(workingDir, 
> "input.xsl"));
>     Source input = new DOMSource(dBuilder.parse(new 
> File(workingDir, "input.xml")));
>     StreamResult output = new StreamResult(new 
> File(workingDir, "output.xml"));
>     TransformerFactory tFactory = TransformerFactory.newInstance();
>     Transformer transformer = tFactory.newTransformer(xsl);
>     transformer.transform(input, output);
> }
> 
> but when I execute xalan with a StreamSource it works fine.  
> Here is my input.xsl file:
> 
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:lxslt="http://xml.apache.org/xslt"; 
> xmlns:customMap="CustomSplit" 
> extension-element-prefixes="customMap" version="1.0">
>     <lxslt:component prefix="customMap" 
> elements="customSplit1 customSplit2 customSplit3">
>         <lxslt:script lang="javaclass" src 
> ="xalan://org.eclipse.xml.xslt.experiment7.CustomSplit"/>
>     </lxslt:component>
> 
>     <xsl:template match="/">
>         <DstRoot>
>             <DstElement1><customMap:customSplit1/></DstElement1>
>             <DstElement2><customMap:customSplit2/></DstElement2>
>             <DstElement3><customMap:customSplit3/></DstElement3>
>         </DstRoot>
>     </xsl:template>
> </xsl:stylesheet>
> 
> Any ideas why this does not work?
> 
> I'm using xalan-j_2_3_1on windows NT.
> 
> 

Reply via email to