You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by pr...@wipro.com on 2005/04/28 12:32:23 UTC

Xerces/Xalan DOM which one should I use?

Hi,

I have couple of questions regarding Xerces and Xalan

First one is why do we have to use these lines , whats the importance of
usign it ? Is this compulsory

    XALAN_USING_XALAN(XalanDocument)
    XALAN_USING_XALAN(XPathEvaluator)
    XALAN_USING_XERCES(XMLPlatformUtils)
    XALAN_USING_XERCES(MemBufInputSource)
    XALAN_USING_XALAN(XalanDOMString)
    XALAN_USING_XALAN(XalanNode)
    XALAN_USING_XALAN(XalanSourceTreeInit)
    XALAN_USING_XALAN(XalanSourceTreeDOMSupport)
    XALAN_USING_XALAN(XalanSourceTreeParserLiaison)
    XALAN_USING_XALAN(XObjectPtr)
    XALAN_USING_XALAN(NodeRefList)
    XALAN_USING_XERCES(LocalFileInputSource)

Second One ,

We are tryign to write a program to perform following things
1. We want to get the value of each tag , modify an XML tag if necessary
, delete an XML tag and store it back to the same XML file.
2. I need to do an XML transformation.
3. I need to do an XML validation.
4. I need to find the difference between two XML files. It could in
ordered or unordered.

1. In the second case what and all need to be initialised ?

2. Are there any API's to find the difference between two XML files or
do I have to perform these things on my own.

3. Should I use DOM or SAX ?

4. I heard both Xalan DOM and Xerces DOM is present , Which one should I
use ?

5. How to use only Xerces DOM or only Xalan DOM ?

6. Is Memory Manager necessary ? if yes please provide me the sample
code on how to use it ?


help me to answer these..

Thanks for the support
-Praveen





________________________________

From: Amit Dang [mailto:amit_dang@intersolutions.stpn.soft.net]
Sent: Tuesday, April 19, 2005 10:49 AM
To: xalan-c-users@xml.apache.org
Subject: Re: How to get an Xpath?


Hi Praveen,
    You need to provide the XML data/stream, it can be via XML File or
in memory. A sample has been provided with Xalan for XML data via file
and for XML data stored in a memory you can use 'MemBufInputSource'. I
am enclosing a .cxx and .hxx file while might be of some help to you.
Hope this helps.

Cheers,
Amit Dang

	----- Original Message -----
	From: praveen.maruvekere@wipro.com
	To: xalan-c-users@xml.apache.org
	Sent: Tuesday, April 19, 2005 10:38 AM
	Subject: How to get an Xpath?

	I have compiled the Xalan 1.9  C++  in Sol 2.8.
	Samples are aslo compiled and I am able to run the EXE's.
	
	Imagine I have an XML file as follows
	
	<PML>
	    <EC>
	            <TN>100-111-99<!-- UPDATE FROM "100-112-0039"
--></TN>
	            <LVL1><!-- DELETE LVL1 -->
	                <AS>aaa</AS>
	            </LVL1>
	            <LV1>
	                <NU>AB/10<!-- UPDATE FROM "AB/11" --></NU>
	            </LV1>
	            <LV1><!-- DELETE LV1 -->
	                <EMP>101</EMP>
	                <DT>10012005</DT>
	            </LV1>
	    </EC>
	</PML>
	
	If I give an input as "UPDATE FROM" the output I should get is
"PML:EC.TN" and  "PML:EC.LV1"
	Similarly if I give an input as "DELETE" I should get the output
as "PML:EC.LVL1" and "PML:EC.LV1[2]"
	
	Is there a way to get this from the Xalan API's ?
	If you have any sample program please do send me...
	
	I checked the sample program present in Xalan , it takes three
parameters "XML file" , "Context" and "XPATH" .
	
	I am not able to understand what should go as input in case of
"context " and "XPATH".
	
	
	Thanks
	-Praveen


Confidentiality Notice

The information contained in this electronic message and any attachments
to this message are intended
for the exclusive use of the addressee(s) and may contain confidential
or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.






Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

Re: Xerces/Xalan DOM which one should I use?

Posted by Axel Weiß <aw...@informatik.hu-berlin.de>.
Am Donnerstag, 28. April 2005 12:32 schrieb 
praveen.maruvekere@wipro.com:
> Hi,
>
> I have couple of questions regarding Xerces and Xalan
>
> First one is why do we have to use these lines , whats the importance
> of usign it ? Is this compulsory
>
>     XALAN_USING_XALAN(XalanDocument)
>     XALAN_USING_XALAN(XPathEvaluator)
>     XALAN_USING_XERCES(XMLPlatformUtils)
>     XALAN_USING_XERCES(MemBufInputSource)
>     XALAN_USING_XALAN(XalanDOMString)
>     XALAN_USING_XALAN(XalanNode)
>     XALAN_USING_XALAN(XalanSourceTreeInit)
>     XALAN_USING_XALAN(XalanSourceTreeDOMSupport)
>     XALAN_USING_XALAN(XalanSourceTreeParserLiaison)
>     XALAN_USING_XALAN(XObjectPtr)
>     XALAN_USING_XALAN(NodeRefList)
>     XALAN_USING_XERCES(LocalFileInputSource)

Hi Praveen,

these macros are wrappers for the 'using'-directive, if namespaces are 
supported by your compiler, empty otherwise.

>
> Second One ,
>
> We are tryign to write a program to perform following things
> 1. We want to get the value of each tag , modify an XML tag if
> necessary , delete an XML tag and store it back to the same XML file.

Generally, in-file manipulations are a bad idea. You should consider 
processing the source file read-only first, and store the results in a 
different tempfile. As a second step, you can move the tempfile to the 
name of the original source.

> 2. I need to do an XML transformation.

This is what xalan is for.

> 3. I need to do an XML validation.

Validation is a matter of enabling validation during parsing. There is 
no method similar to 'validate this piece of XML'.

> 4. I need to find the difference between two XML files. It could in
> ordered or unordered.

This task can become rather difficult!

> 1. In the second case what and all need to be initialised ?
>
> 2. Are there any API's to find the difference between two XML files
> or do I have to perform these things on my own.

There is no standard describing the difference between two XML files. In 
fact, you can choose rather different measures about what counts as a 
difference and what does not. In the simplest case, you run 'diff' and 
get the text-based differences - but this might not be what you intend. 
In all other cases you have to compare two representations (e.g. DOM 
trees) against each others and find the differences according to your 
preferred rules.

> 3. Should I use DOM or SAX ?

In order to perform a rule-based content difference checker, I would 
prefer DOM, since the algorithms can be recursive, and you can 
formulate just any rules. (But I may be wrong here, because I have only 
little experience with SAX).

> 4. I heard both Xalan DOM and Xerces DOM is present , Which one
> should I use ?
>
> 5. How to use only Xerces DOM or only Xalan DOM ?

If you want to perform XML-stylesheet processing, there is no need to 
program it again. You can use the Xalan executable as a simple 
transformation tool.

On the other hand, if your application is required to perform stylesheet 
processing by it's own, there is no need to use a second DOM 
representation. Xalan accepts both DOM variants as input.

> 6. Is Memory Manager necessary ? if yes please provide me the sample
> code on how to use it ?

It's not necessary to use a custom MemoryManager, as memory management 
falls back to stdlib-behaviour. However, if you encounter performance 
issues, MemoryManager may help you.


-- 
Humboldt-Universität zu Berlin
Institut für Informatik
Signalverarbeitung und Mustererkennung
Dipl.-Inf. Axel Weiß
Rudower Chaussee 25
12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org