Jump to content

katja.radelicki@colruyt.be

Members
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About katja.radelicki@colruyt.be

  • Rank
    Newbie
  1. Dear members,what are the possible ways to show an XML file (withe the layout of a table accordance with the XSL) in a web application written in java? The xml file has to be transformed by a corresponding xsl file.(is it possible in jsp? in jdom? ...)Regards,Katja
  2. It is some bug and normally it it solved in jdk 1.5see http://mail-archives.apache.org/mod_mbox/x....jira@brutus%3e But I tried to use jdk 1.5 and I still receive this error.Is there somebody who knows what to do?Thanks in advance!
  3. Hello,is it possible to create an XML file with SAX with Validation (using an xsd)? I know it is possible to read an XML file with SAX with Validation and to write an XML file with SAX. But now I want to create a valid XML file with SAX.Writing with SAX I do like this: public class SaxWriter { public static void main(String[] args) { try{FileOutputStream fileOutputStream=new FileOutputStream("C:/_develop/asja/lib/local/saxxmlliblocal/properties/xml/catalogueSAXWithoutValidation.xml"); OutputFormat outputFormat=new OutputFormat("XML","ISO-8859-1",false); outputFormat.setIndent(0); XMLSerializer xmlSerializer=new XMLSerializer(fileOutputStream,outputFormat); ContentHandler contentHandler= xmlSerializer.asContentHandler(); Catalogue catalogue=getCatalogue(10,10); writeXMLFile(contentHandler,catalogue); fileOutputStream.close(); }catch (Exception e) { e.printStackTrace(); }}public static void writeXMLFile(ContentHandler contentHandler,Catalogue catalogue){ try{ contentHandler.startDocument(); contentHandler.startElement("", "", "catalogue", null); contentHandler.startElement("", "", "date_created", null); *…* contentHandler.endElement("", "", "cds"); contentHandler.endElement("", "", "catalogue"); contentHandler.endDocument(); }catch (SAXException saxException){ saxException.printStackTrace(); } }} I can write the XML file and than read it with validation, but I want to avoid reading the XML-file again.Regards,Katja
  4. Hello,I try to validate a DOM Document using: SchemaFactory factory=SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);Source schemaFile=new StreamSource("myschema.xsd");schema schema=factory.newSchema(schemaFile);Validator validator=schema.newValidator();validator.validate(new DOMSource(document)); I don't validate using the parse(File) method, because I already have a DOM Tree in memory.BUT now I receive the following error: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'catalogue'.at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)at org.apache.xerces.jaxp.validation.XMLSchemaValidator.validate(Unknown Source)at javax.xml.validation.Validator.validate(Unknown Source) catalogue is my rootElement.A part of the XML file: <?xml version="1.0" encoding="UTF-8"?><catalogue><date_created><day>1</day><month>7</month><year>2008</year></date_created><date_modified><day>1</day><month>7</month><year>2008</year></date_modified> And a part of the XSD schema: <?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="catalogue"> <xsd:complexType> <xsd:sequence> <xsd:element ref="date_created"/> <xsd:element ref="date_modified"/> <xsd:element ref="comment"/> <xsd:element ref="books"/> <xsd:element ref="cds"/> </xsd:sequence> </xsd:complexType> </xsd:element> (I'm using jdk 1.4.)Does somebody know how to solve this?Thank you!Katja
  5. Hello,I have the same error:org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'catalogue'.at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)at org.apache.xerces.jaxp.validation.XMLSchemaValidator.validate(Unknown Source)at javax.xml.validation.Validator.validate(Unknown Source)A part of my XSD schema: <?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="catalogue"> <xsd:complexType> <xsd:sequence> <xsd:element ref="date_created"/> <xsd:element ref="date_modified"/> <xsd:element ref="comment"/> <xsd:element ref="books"/> <xsd:element ref="cds"/> </xsd:sequence> </xsd:complexType> </xsd:element> And a part of the XML file: <?xml version="1.0" encoding="UTF-8"?><catalogue><date_created><day>1</day><month>7</month><year>2008</year></date_created><date_modified><day>1</day><month>7</month><year>2008</year></date_modified> I try to validate a DOM Document using: SchemaFactory factory=SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);Source schemaFile=new StreamSource("myschema.xsd");schema schema=factory.newSchema(schemaFile);Validator validator=schema.newValidator();validator.validate(new DOMSource(document)); I don't validate using the parse(File) method, because I already have a DOM Tree in memory.Does somebody know how I can solve this?Thank you,Katja
×
×
  • Create New...