aspose file tools*
The moose likes XML and Related Technologies and the fly likes xalan Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xalan" Watch "xalan" New topic
Author

xalan

aude tantot
Ranch Hand

Joined: May 21, 2001
Posts: 39
when i execute my code, a message tells me the xml file i've passed can't be parsed. can u help me?

import javax.swing.*;
import java.io.*;
import org.apache.xalan.xslt.*;

public class generateClass
{
generateClass(File f)
{
XSLTProcessor processor = XSLTProcessorFactory.getProcessor(new org.apache.xalan.xpath.xdom.XercesLiaison());
XSLTInputSource input=new XSLTInputSource(f.getPath());
XSLTInputSource style=new XSLTInputSource("schema.xsl");
XSLTResultTarget result=new XSLTResultTarget("result.html");
try
{
processor.process(input,style,result);
}
catch(org.xml.sax.SAXException e){}
}
}
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
What is the exact message? Can you also post your XML file here?
Thanks!
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
aude tantot
Ranch Hand

Joined: May 21, 2001
Posts: 39
here's my xml:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="schema.xsl"?>
<!-- edited with XML Spy v3.5 (http://www.xmlspy.com) by ismea (ismea) -->
<!DOCTYPE schema [
<!ELEMENT schema (primitive*, class*, node*)>
<!ELEMENT primitive (p_name, list+)>
<!ELEMENT class (c_name, c_desc?, subclass*, c_att*, content*)>
<!ELEMENT c_att (c_att_name, c_att_desc?, c_att_pri, c_att_req)>
<!ELEMENT node (n_name, n_desc?, memberof*, in_att*, ext_att*)>
<!ELEMENT in_att (in_att_name, in_att_desc?, in_att_pri, in_att_req)>
<!ELEMENT ext_att (ext_att_name, ext_att_desc?, ext_att_pri, ext_att_req)>
<!ELEMENT p_name (#PCDATA)>
<!ELEMENT list (#PCDATA)>
<!ELEMENT c_name (#PCDATA)>
<!ELEMENT c_desc (#PCDATA)>
<!ELEMENT subclass (#PCDATA)>
<!ELEMENT content (#PCDATA)>
<!ELEMENT n_name (#PCDATA)>
<!ELEMENT n_desc (#PCDATA)>
<!ELEMENT memberof (#PCDATA)>
<!ELEMENT c_att_name (#PCDATA)>
<!ELEMENT c_att_desc (#PCDATA)>
<!ELEMENT c_att_pri (#PCDATA)>
<!ELEMENT c_att_req (#PCDATA)>
<!ELEMENT in_att_name (#PCDATA)>
<!ELEMENT in_att_desc (#PCDATA)>
<!ELEMENT in_att_pri (#PCDATA)>
<!ELEMENT in_att_req (#PCDATA)>
<!ELEMENT ext_att_name (#PCDATA)>
<!ELEMENT ext_att_desc (#PCDATA)>
<!ELEMENT ext_att_pri (#PCDATA)>
<!ELEMENT ext_att_req (#PCDATA)>
]>
<schema>
<primitive>
<p_name>C_CV_Qualifier</p_name>
<list>C_No_CV_QUALIFIER</list>
<list>C_Const_CV_QUALIFIER</list>

</primitive>
<class>
<c_name>C_TEMPLATE_INST</c_name>
<c_desc> A class including nodes used to represent template instantiations. An instantiation references a C_TEMPLATE_ID (attribute has_template_id) node to specify actual argument to the associated template generic parameters. Such an instantiation is included in the namespace containing the template (has_enclosing_scope). Implicit instantiation are represented by C_IMP_TEMPLATE_INST subclass. </c_desc>
<subclass>C_DECLARATION</subclass>
<subclass>C_REGION_ITEM</subclass>
<c_att>
<c_att_name> has_template_id</c_att_name>
<c_att_desc>a C_TEMPLATE_ID node which describes the association of actual arguments to the template generic parameter.</c_att_desc>
<c_att_pri>true</c_att_pri>
<c_att_req>false</c_att_req>
</c_att>
<content>C_IMP_TEMPLATE_INST</content>
<content>c_func_inst</content>
<content>c_class_inst</content>
</class>
<node>
<n_name>c_literal</n_name>
<n_desc>A C_EXPRESSION node used to describe C/C++ literal including integer literal, floating literal, and string literal. A C_STATIC_VALUE node referenced by has_value attribute represents the value of the literal. </n_desc>
<memberof>C_EXPRESSION</memberof>
<memberof>C_ACTUAL</memberof>
<in_att>
<in_att_name> has_temp</in_att_name>
<in_att_desc> An attribute which points to an Int_32 value that, may be used to represent any temporary user-defined information. This attribute is always set to 0 upon saving the unit.</in_att_desc>
<in_att_pri>true</in_att_pri>
<in_att_req>false</in_att_req>
</in_att>
<in_att>
<in_att_name> has_srcpos</in_att_name>
<in_att_desc>The source file position (Source_Info) of the first token associated with the node.</in_att_desc>
<in_att_pri>true</in_att_pri>
<in_att_req>false</in_att_req>
</in_att>
<in_att>
<in_att_name> has_type_id</in_att_name>
<in_att_desc> Points toa C_TYPE_ID node representing the type of the expression.</in_att_desc>
<in_att_pri>false</in_att_pri>
<in_att_req>true</in_att_req>
</in_att>
<ext_att>
<ext_att_name> has_value </ext_att_name>
<ext_att_desc>An attribute which points to a C_STATIC_VALUE node denoting the literal value.</ext_att_desc>
<ext_att_pri>true</ext_att_pri>
<ext_att_req>true</ext_att_req>
</ext_att>
</node>
</schema>
i checked it with xml spy, it tells it well formed and valid.
here's the xsl that i use
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">

<html>
<body>

<h1>VI PRIMITIVES</h1>
<br/> <xsl:for-each select="schema/primitive" >

<p>
<h2><br>enum <xsl:value-of select="p_name"/>{</br></h2>

<xsl:apply-templates select="list"/>
<br>}</br>
</p>

</xsl:for-each>
<h1>VII CLASSES</h1>
<br/> <xsl:for-each select="schema/class" >
<p>

<h2><br><xsl:value-of select="c_name"/></br></h2>
<br><xsl:value-of select="c_desc"/></br>
<h3><br>SUBCLASS OF:</br></h3>
<xsl:apply-templates select="subclass"/>
<h3><br>EXTENDED CLASS ATTRIBUTE:</br></h3>
<xsl:apply-templates select="c_att"/>
<h3><br>CONTENT : </br></h3>
<xsl:apply-templates select="content"/>

</p>
</xsl:for-each>
<h1>VIII NODES</h1>
<br/> <xsl:for-each select="schema/node" >
<p>
<h2> <br><xsl:value-of select="n_name"/></br></h2>
<br><xsl:value-of select="n_desc"/></br>
<h3><br>MEMBER OF:</br></h3>
<xsl:apply-templates select="memberof"/>
<h3><br>INHERITED CLASS ATTRIBUTES</br></h3>
<xsl:apply-templates select="in_att"/>
<h3><br>EXTENDED NODE ATTRIBUTES</br></h3>
<xsl:apply-templates select="ext_att"/>
</p>
</xsl:for-each>

</body>
</html>
</xsl:template>
<xsl:template match="schema/primitive/list">
<br><xsl:value-of select="."/></br>
</xsl:template>
<xsl:template match="schema/class/subclass">
<br><xsl:value-of select="."/></br>
</xsl:template>
<xsl:template match="schema/class/c_att">
<br><b><xsl:value-of select="./c_att_name"/></b></br>
<br><xsl:value-of select="./c_att_desc"/>
primary : <xsl:value-of select="./c_att_pri"/> required : <xsl:value-of select="c_att/c_att_req"/></br>
<br/>
</xsl:template>

<xsl:template match="schema/class/content">
<br><xsl:value-of select="."/></br>
</xsl:template>
<xsl:template match="schema/node/memberof">
<br><xsl:value-of select="."/></br>
</xsl:template>
<xsl:template match="schema/node/in_att">
<br><b><xsl:value-of select="./in_att_name"/></b></br>
<br><xsl:value-of select="./in_att_desc"/>
primary : <xsl:value-of select="./in_att_pri"/> required : <xsl:value-of select="./in_att_req"/></br>
<br/>
</xsl:template>
<xsl:template match="schema/node/ext_att">
<br><b><xsl:value-of select="./ext_att_name"/></b></br>
<br><xsl:value-of select="./ext_att_desc"/>
primary : <xsl:value-of select="./ext_att_pri"/> required : <xsl:value-of select="./ext_att_req"/></br>
<br/>
</xsl:template>

</xsl:stylesheet>
and here's the message error
c:\...\exemple.xml; Line 0; Column 0
XSL Error: Could not parse c:\...\exemple.xml document!
XSL Error: SAX Exception
i really can't see what's the matter
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
You forgot to close the xsl:stylesheet tag in your xsl. Simply include </xsl:stylesheet> at the end of your xsl file and it should work fine.
Problems like this can be easily solved if you first try to open your XML file in a browser( IE/Netscape). That's exactly what I did and it clearly told me the xsl:stylesheet tag was not closed!! Then I commented out the stylesheet declaration in XML and was able to open the file in IE.
Browsers are great tools for XML development. You should make it a practice to use them.
Cheers!
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
aude tantot
Ranch Hand

Joined: May 21, 2001
Posts: 39
thanks for the interest in my pb. The </xsl:stylesheet> tag actually is in my xsl, the matter doesn't come from there, and it's still making me crazy.
i don't think the pb comes from the xsl sheet, 'cause i succeed in transforming my xml with that xsl thru xml spy
[This message has been edited by aude tantot (edited June 08, 2001).]
aude tantot
Ranch Hand

Joined: May 21, 2001
Posts: 39
got a clue!
when i load the xml in ie5, only the skeleton xsl appear with no data from the xml, in on the good way i think....
aude tantot
Ranch Hand

Joined: May 21, 2001
Posts: 39
for the xalan pb, can it comes from :new org.apache.xalan.xpath.xdom.XercesLiaison()?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xalan