Rehrl, Alwin Taro | 2 Aug 2004 13:01
Picon

Parsing XML documents received from a socket

Dear ML,

I'm asking this on behalf of a colleague of mine. But I'm also interested in
possible
answers. We don't want to use a different parser.

Here's the request:
hello

i have the following problematic.
i'm reading several xml documents after each other from a network socket
and i would like to process them with a sax parser.
problem is: documents can have only one root node and the parser does not
know where to stop the processing of the data read from the incoming
stream and i have a parsing problem.

there is a solution for that on the web site:
(http://xml.apache.org/xerces2-j/samples-socket.html) but since i cannot
change the protocol i cannot use this solution.

with the following restrictions:
- xml declarations are omitted(this is the situation in my case)
- same encoding is used for all documents
my solution would be:
i'm creating a special InputStream that would encapsulate all the
documents read from the socket into one big virtual document.
<?xml version="1.0" ?><virtualDocument>[here are the xml documents read
from the network]</virtualDocument>
and with a special ContentHandler that would emulate startDocument and
endDocument methods for the real ContentHandler implementation.
(Continue reading)

Usorov, Evgeny | 2 Aug 2004 14:57
Picon

derivation by restriction and <choice> to <sequence>- definition 2

Hallo 

i could localize the problem of converting <choice> to <sequence> in derivation by restriction problem:

if i define only:

<xs:complexType name="basis_typ">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
		<xs:element name="foo" minOccurs="0" maxOccurs="unbounded"/>
		<xs:element name="bar" minOccurs="0" maxOccurs="unbounded"/>
	</xs:choice>
</xs:complexType>

to
	<xs:complexType name="derived_test_typ">
		<xs:complexContent>
			<xs:restriction base="basis_typ">
					<xs:sequence>
						<xs:element name="foo" minOccurs="2" maxOccurs="2"/>
						<xs:element name="bar" minOccurs="4" maxOccurs="4"/>
					</xs:sequence>
			</xs:restriction>
		</xs:complexContent>
	</xs:complexType>

all is fine an valid. But if i add an element before the <choice>-section i get errors:
<xs:complexType name="basis_typ">
	<xs:sequence>
		<xs:element name="added_element"/>
		<xs:choice minOccurs="0" maxOccurs="unbounded">
(Continue reading)

Benjamin Kolin | 2 Aug 2004 22:39

Schema processing recursion question

Given a schema was a recursive element, like this:
 
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" 
 
targetNamespace="http://localhost:8080/mytest" xmlns:tns="http://localhost:8080/mytest">
 <xs:complexType name="symbolType">
  <xs:sequence>
   <xs:element name="name" type="xs:string" />
   <xs:element name="symbol" type="tns:symbolType" minOccurs="0"
 
maxOccurs="1"/>
  </xs:sequence>
 </xs:complexType>
<xs:element name="getQuote">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="symbol" type="tns:symbolType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
 
What would be the best way to programmatically control the level of recursion?  I need to be able to specify "this element is recursive, but only up to 10 levels deep, and anything deeper should be considered an error."  Thank you.
 
-Ben Kolin
Lingzhi Zhang | 2 Aug 2004 23:30
Picon

Re: Schema processing recursion question

What do you mean the "best" way? There are several ways that you could
program it.

----- Original Message -----
From: Benjamin Kolin <ben <at> westbridgetech.com>
Date: Mon, 2 Aug 2004 13:39:00 -0700
Subject: Schema processing recursion question
To: xerces-j-user <at> xml.apache.org

Given a schema was a recursive element, like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"

targetNamespace="http://localhost:8080/mytest"
xmlns:tns="http://localhost:8080/mytest">
 <xs:complexType name="symbolType">
  <xs:sequence>
   <xs:element name="name" type="xs:string" />
   <xs:element name="symbol" type="tns:symbolType" minOccurs="0" 

maxOccurs="1"/>
  </xs:sequence>
 </xs:complexType>
<xs:element name="getQuote">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="symbol" type="tns:symbolType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

 
What would be the best way to programmatically control the level of
recursion?  I need to be able to specify "this element is recursive,
but only up to 10 levels deep, and anything deeper should be
considered an error."  Thank you.

-Ben Kolin
Maneesh Sahu | 2 Aug 2004 23:40

RE: Schema processing recursion question

Is there any way besides implementing a ContentHandler? Something more
native to the parser engine?

--ms

-----Original Message-----
From: Lingzhi Zhang [mailto:lzzhang <at> gmail.com] 
Sent: Monday, August 02, 2004 2:30 PM
To: xerces-j-user <at> xml.apache.org
Subject: Re: Schema processing recursion question

What do you mean the "best" way? There are several ways that you could
program it.

----- Original Message -----
From: Benjamin Kolin <ben <at> westbridgetech.com>
Date: Mon, 2 Aug 2004 13:39:00 -0700
Subject: Schema processing recursion question
To: xerces-j-user <at> xml.apache.org

Given a schema was a recursive element, like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"

targetNamespace="http://localhost:8080/mytest"
xmlns:tns="http://localhost:8080/mytest">
 <xs:complexType name="symbolType">
  <xs:sequence>
   <xs:element name="name" type="xs:string" />
   <xs:element name="symbol" type="tns:symbolType" minOccurs="0" 

maxOccurs="1"/>
  </xs:sequence>
 </xs:complexType>
<xs:element name="getQuote">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="symbol" type="tns:symbolType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

 
What would be the best way to programmatically control the level of
recursion?  I need to be able to specify "this element is recursive,
but only up to 10 levels deep, and anything deeper should be
considered an error."  Thank you.

-Ben Kolin

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe <at> xml.apache.org
For additional commands, e-mail: xerces-j-user-help <at> xml.apache.org
Ben Bookey | 3 Aug 2004 18:24
Picon

Differences between


1) Could anyone explain why my xml-generator Tomcat web-app (supplied with
xmlParserAPIs.jar and xercesImpl.jar in the extended path) doesnt work until
I copy the xerces.jar into this path aswell. Isnt xmlParserAPIs.jar and
xercesImpl.jar enough ?

2) what is the differences between the xerces.jar supplied with Java SDK 1.4
and the version from apache?
Could there be a problem of collison?

regards

Ben

+-------------------------------------------------------------------+
| GIStec GmbH - Ihr Partner für GIS - Technologie                   |
|                                                                   |
| Ben Bookey                                                        |
| Ben.Bookey <at> gistec-online.de           Fraunhoferstraße 5          |
| Tel         0 61 51 / 155 - 254       D-64283 Darmstadt           |
| Fax         0 61 51 / 155 - 259       http://www.gistec-online.de |
|                                                                   |
| http://www.ingeoic.de              http://www.geo-watermarking.de |
+-------------------------------------------------------------------+
Satish Kumar | 3 Aug 2004 18:31
Favicon

non-xml to xml using transformations

hai,

  I'm wriring a program to convert a non-xml file to xml file with transformations.
 
  As sax events are genereated the transformatins also should take place. But it does not happen in my case.  I have spefified a 

contentHandler.startDocument()
contentHandler.Elemet() and all the necesasry.....
 
  i Have also extednd the XML reader interface and overrideen the aprse method. It still does not work. CAn anyone help me  out and its very urgent.

thanking you in advance.

rgds,
satish




ANN: new Xerces-enabled XML Editor

DIR=ltr>

 
[announce]Dear Xerces-J User community,
 

Stylus Studio is pleased to announce Stylus Studio 5 Home Edition, a new, value-priced version of our award-winning XML IDE. Stylus Studio 5 Home Edition is specifically designed for learning or working with XML in educational, training, or home settings, and is available now for only $49 (USD) for a single-user license. The latest addition to the Stylus Studio family of XML productivity tools offers substantially more XML development features compared to other low-cost XML tools, including:

 

* XML Editor - Full support for intelligent XML editing (Sense:X); text, tree, and schema XML editing views; full parsing and validation support, fully integrated XML parsing and error reporting with Xerces-J.

* XML Schema Editor - Visually develop XML data models using text, tree, or diagram views

* XSLT Editor - A productive, intuitive environment for developing XSLT stylesheets, including a visual XSLT mapping tool

* XSLT Debugger - Set breakpoints and step through the evaluation of any XSLT stylesheet to locate errors

* DTD Editor - Visually develop document type definitions

* XPath Tools - Visually evaluate XPath expressions; full support for XPath 1.0 and 2.0

* Integrated Java/JSP IDE - Ideal for working with Java and XML technologies.

 

For more information about Stylus Studio 5 Home Edition is available at the Stylus Studio website at: http://www.stylusstudio.com/stylus_home_edition.html

 

You can download a free trial of Stylus Studio 5 Home Edition at:

http://www.stylusstudio.com/home_edition_download.html

 

Sincerely,

The Stylus Studio Team

http://www.stylusstudio.com

Jason Dusek | 4 Aug 2004 00:36
Picon
Favicon

Outputting HTML elements to XHTML

Hi Everyone,

I would like to make up an HTML document using HTML*ElementImpl classes, and 
then I would like to serialize it as XHTML. Here is how I set up my serializer:

   OutputFormat output = new OutputFormat();
   output.setDoctype(OutputFormat.DTD.XHTMLPublicId,
     OutputFormat.DTD.XHTMLSystemId);
   output.setIndenting(true);
   XMLSerializer cereal = new XMLSerializer(System.out, output);

My document starts like this:

   HTMLDocumentImpl html = new HTMLDocumentImpl();
   html.setTitle("foo");
   HTMLDivElementImpl aDiv = new HTMLDivElementImpl(html, "div");
   html.getBody().appendChild(aDiv);

Now, if I just take some random XML document with 'div' and similar tags in it, 
and then output it, they come out lower case. But these HTML*ElementImpl classes 
always have uppercase tags. Is there an easy way to force them into lower case 
mode? Or do I have to replace them to get valid XHTML?

_jason
Jacob Kjome | 4 Aug 2004 06:01
Favicon

Re: Differences between

At 06:24 PM 8/3/2004 +0200, you wrote:

>1) Could anyone explain why my xml-generator Tomcat web-app (supplied with
>xmlParserAPIs.jar and xercesImpl.jar in the extended path) doesnt work until
>I copy the xerces.jar into this path aswell. Isnt xmlParserAPIs.jar and
>xercesImpl.jar enough ?

What do you mean by "extended path"?  What version of Tomcat are you 
using?  To make sure your version of Xerces gets used, replace the ones 
provided in Tomcat's common/endorsed directory.  Any other xerces version 
will be ignored since this will override it.  And are you accessing the 
Xerces API or just the standard JAXP, DOM, and SAX api's?  You mention 
"xerces.jar".  That leads me to believe that you coded directly to 
Xerces-1.x.x.  If the package names or class names don't coincide with 
Xerces2, then you'd end up using Xerces1 instead of Xerces2.

>2) what is the differences between the xerces.jar supplied with Java SDK 1.4
>and the version from apache?
>Could there be a problem of collison?

Xerces isn't provided with JDK1.4.  Where did you get that idea?  Crimson 
is the implemented parser in JDK1.4.  Xalan actually is included in JDK1.4, 
so maybe you are confusing libraries here?  But note that Tomcat, by adding 
xercesImpl.jar and xml-apis.jar to common/endorsed, essentially makes 
xerces2 part of the JDK by making the library "endorsed".

Jake

>regards
>
>Ben
>
>+-------------------------------------------------------------------+
>| GIStec GmbH - Ihr Partner für GIS - Technologie                   |
>|                                                                   |
>| Ben Bookey                                                        |
>| Ben.Bookey <at> gistec-online.de           Fraunhoferstraße 5          |
>| Tel         0 61 51 / 155 - 254       D-64283 Darmstadt           |
>| Fax         0 61 51 / 155 - 259       http://www.gistec-online.de |
>|                                                                   |
>| http://www.ingeoic.de              http://www.geo-watermarking.de |
>+-------------------------------------------------------------------+
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-j-user-unsubscribe <at> xml.apache.org
>For additional commands, e-mail: xerces-j-user-help <at> xml.apache.org

Gmane