You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Sebastian Will <ju...@gmx.net> on 2001/05/17 09:32:18 UTC

Validation using DOM Parser

Hi all, 
this might be a questions that's already been asked, but the mailing archive is not reachable at the moment. I'm fairly new to Xerces and while I initially worked with the XML4J from alphaworks.ibm.com, I'm now switching to Xerces which I just downloaded a sec ago (I know they should be almost the same, but...). With XML4J, there was at least in the most recent version no possibility to validate a XML file when I create a org.w3c.dom.Document using the DOMParser. I registered an ErrorHandler, who works if I use wrong XML syntax as an input, but it does not seem to report any violations against a internal DTD. 

Please correct me, if I'm wrong, but this XML file is not valid:

<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE article
[
<!ELEMENT title (#PCDATA)>
]>
<title>Test
   <elem>bla</elem>
</title>

My Java application does the following:

DOMParser parser = new DOMParser();
parser.setErrorHandler(new DefaultErrorHandler());
...
parser.parse(Util.genURI(files[i].getAbsolutePath()));
document = parser.getDocument();

Shouldn't be parse errors reported by the DefaultErrorHandler I registerd within the parser? Or do I have to use a SAXParser instead, he does validate the XML data, doesn't he? 

Please give me a kick into the right direction, thanks!

Sebastian Will



nodeset() extention in xalan - please help.

Posted by Kiran Halwai <kh...@winphoria.com>.
Hello:

I could not find xalan user mailing list so posting it here - sorry about
that.

I am struggling with nodeset() extention in xalan. Following are the
templates. I have included xalan.jar,
xerces.jar, bsf.jar in the classpath - rather in lib directory of tomcat.
I am getting following error msg -

"Call to extension function failed: http://xml.apache.org/xalan".

I would really appreciate your help to solve this problem.

Also, is it possible to pass a path of XML element to nodeset(). XML file
could like this.

  <start>
             <option value="alf">A</option>
             <option value="bar">B</option>
             <option value="cat">C</option>
             <option value="dog">D</option>
             <option value="elf">E</option>
             <option value="foo">F</option>
     </start>

Best Regards,
Kiran

-----------------------------------------------------------------
Application.xsl
---------
<xsl:template name="wms_pointcode-extra">
  <xsl:call-template name="generic-select">

   <xsl:with-param name="label">My List </xsl:with-param>
   <xsl:with-param name="name">listName</xsl:with-param>
   <xsl:with-param name="options">
     <start>
             <option value="alf">A</option>
             <option value="bar">B</option>
             <option value="cat">C</option>
             <option value="dog">D</option>
             <option value="elf">E</option>
             <option value="foo">F</option>
     </start>
      </xsl:with-param>
 </xsl:call-template>
</xsl:template>

-------------------------------------------------------------------
Generic.xsl
--------

</xsl:stylesheet><?xml version="1.0"?>
                <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                                xmlns:xalan="http://xml.apache.org/xalan"
                                exclude-result-prefixes="xalan">

<xsl:output method="html"/>

<xsl:template name="generic-select">
  <xsl:param name="label"/>
 <xsl:param name="options"/>
 <xsl:param name="name"/>

 <tr align="center">
  <td width="50%"><xsl:value-of select="$label"/></td>
  <td width="50%" align="left">
    <select>
      <xsl:attribute name="name">
       <xsl:value-of select="$name"/>
     </xsl:attribute>
     <xsl:for-each select="xalan:nodeset($options)/start//*">
      <option>
       <xsl:attribute name="value">
        <xsl:value-of select="./@value"/>
       </xsl:attribute>
       <xsl:value-of select="."/>
      </option>
     </xsl:for-each>
    </select>
  </td>
 </tr>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Validation using DOM Parser

Posted by René Jensen <lu...@tbkol.dk>.
Citat Sebastian Will <ju...@gmx.net>:

> 
> Please give me a kick into the right direction, thanks!
> 
> Sebastian Will

You could start by reading the instructions on

http://xml.apache.org/xerces-j/index.html

You have to turn on validation, or else the parser will just parse, and 
generate a DOM, without validating your document.

You will find what you need under 'features' in the menu to the left.

         \\|//
         (@ @)
-----oOOo-(_)-oOOo-----
      René Jensen
   lundeman@tbkol.dk

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org