You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by pm <pi...@yahoo.com> on 2006/03/25 01:12:40 UTC

setting attribute in Xalan C++

Hi,

I have a question on Xalan C++. I am trying to perform
very basic XML operations like
getting/setting/adding/removing attributes and
elements in a DOM tree. My code needs to use the XPath
passed by the user to perform these operations. I
found that the sample code available on the website is
mostly for more advanced features like XSL stylesheet
and transformation (except for the example
SimpleXPathAPI). Is there any other sample code
available that I can look at?

I could write the function for getting an attribute
value using the XPathEvaluator::evaluate() function.
But while trying to set an attribute value, I am
getting an exception. My code is as follows.

XalanNode* const	theResultNode =
theEvaluator.selectSingleNode(theDOMSupport,
theContextNode, XalanDOMString(buf).c_str(),
thePrefixResolver);
const XalanDOMString	valueXDS(value);
if (theResultNode)
	((XalanAttr *)&theResultNode)->setValue(valueXDS);

Here setValue is cauing the exception. theResultNode
is supposed to point to the attribute node whose value
is getting set. Can somebody help me with this? Am I
using the right classes and APIs?

Many thanks.

Pinaki

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: setting attribute in Xalan C++

Posted by Sean <sr...@yahoo.co.uk>.
What you could do is use Xerces as the XML DOM - i.e. for loading/saving XML or building an XML
tree.

You could then use Xalan when you need to do XPath (or XSL).

You could use Xalan with Xerces, on the Xerces document object, or else use Xalan seperately on
the XML saved as a file.  The second approach is simpler to code.

Sean

--- pm <pi...@yahoo.com> wrote:

> Thanks for the reply. Xerces would have been perfectly
> fine, but it does not support XPath. As I said in my
> mail, my application needs to use XPath provided by
> the user to locate the node and then perform certain
> operations on it. Is the latter feature not supported
> in Xalan?
> 
> Thanks.
> 
> Pinaki
> 
> --- Sean <sr...@yahoo.co.uk> wrote:
> 
> > Hello,
> > 
> > it sounds like all you need is an XML DOM, not an
> > implementation of XSL.
> > 
> > You could just use Apache Xerces on its own - it has
> > samples for creating XML elements.
> > 
> > Sean
> > 
> > --- pm <pi...@yahoo.com> wrote:
> > 
> > > Hi, I am still waiting for an answer on this. Can
> > > somebody please help! I noticed that the setValue
> > or
> > > setNodeValue functions in XalanSourceTreeAttr
> > class
> > > are written to just throw an exception and there
> > is no
> > > other functionality. In fact, this is the case
> > with
> > > all the 'set' functions in this class or even
> > other
> > > classes like XalanSourceTreeElement. Does this
> > mean
> > > that none of these functionalities are implemented
> > in
> > > the Xalan library and the user needs to rewrite
> > these
> > > functions to get the desired functionality?
> > > 
> > > Please help. Any help will be greatly appreciated.
> > > 
> > > Thank you.
> > > 
> > > - Pinaki
> > > 
> > > 
> > > --- pm <pi...@yahoo.com> wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I have a question on Xalan C++. I am trying to
> > > > perform
> > > > very basic XML operations like
> > > > getting/setting/adding/removing attributes and
> > > > elements in a DOM tree. My code needs to use the
> > > > XPath
> > > > passed by the user to perform these operations.
> > I
> > > > found that the sample code available on the
> > website
> > > > is
> > > > mostly for more advanced features like XSL
> > > > stylesheet
> > > > and transformation (except for the example
> > > > SimpleXPathAPI). Is there any other sample code
> > > > available that I can look at?
> > > > 
> > > > I could write the function for getting an
> > attribute
> > > > value using the XPathEvaluator::evaluate()
> > function.
> > > > But while trying to set an attribute value, I am
> > > > getting an exception. My code is as follows.
> > > > 
> > > > XalanNode* const	theResultNode =
> > > > theEvaluator.selectSingleNode(theDOMSupport,
> > > > theContextNode, XalanDOMString(buf).c_str(),
> > > > thePrefixResolver);
> > > > const XalanDOMString	valueXDS(value);
> > > > if (theResultNode)
> > > > 	((XalanAttr
> > *)&theResultNode)->setValue(valueXDS);
> > > > 
> > > > Here setValue is cauing the exception.
> > theResultNode
> > > > is supposed to point to the attribute node whose
> > > > value
> > > > is getting set. Can somebody help me with this?
> > Am I
> > > > using the right classes and APIs?
> > > > 
> > > > Many thanks.
> > > > 
> > > > Pinaki
> > > > 
> > > >
> > __________________________________________________
> > > > Do You Yahoo!?
> > > > Tired of spam?  Yahoo! Mail has the best spam
> > > > protection around 
> > > > http://mail.yahoo.com 
> > > > 
> > > 
> > > 
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> > protection around 
> > > http://mail.yahoo.com 
> > > 
> > 
> > 
> > ___________
> > Sean Ryan
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 


___________
Sean Ryan

Re: setting attribute in Xalan C++

Posted by pm <pi...@yahoo.com>.
Thanks for the reply. Xerces would have been perfectly
fine, but it does not support XPath. As I said in my
mail, my application needs to use XPath provided by
the user to locate the node and then perform certain
operations on it. Is the latter feature not supported
in Xalan?

Thanks.

Pinaki

--- Sean <sr...@yahoo.co.uk> wrote:

> Hello,
> 
> it sounds like all you need is an XML DOM, not an
> implementation of XSL.
> 
> You could just use Apache Xerces on its own - it has
> samples for creating XML elements.
> 
> Sean
> 
> --- pm <pi...@yahoo.com> wrote:
> 
> > Hi, I am still waiting for an answer on this. Can
> > somebody please help! I noticed that the setValue
> or
> > setNodeValue functions in XalanSourceTreeAttr
> class
> > are written to just throw an exception and there
> is no
> > other functionality. In fact, this is the case
> with
> > all the 'set' functions in this class or even
> other
> > classes like XalanSourceTreeElement. Does this
> mean
> > that none of these functionalities are implemented
> in
> > the Xalan library and the user needs to rewrite
> these
> > functions to get the desired functionality?
> > 
> > Please help. Any help will be greatly appreciated.
> > 
> > Thank you.
> > 
> > - Pinaki
> > 
> > 
> > --- pm <pi...@yahoo.com> wrote:
> > 
> > > Hi,
> > > 
> > > I have a question on Xalan C++. I am trying to
> > > perform
> > > very basic XML operations like
> > > getting/setting/adding/removing attributes and
> > > elements in a DOM tree. My code needs to use the
> > > XPath
> > > passed by the user to perform these operations.
> I
> > > found that the sample code available on the
> website
> > > is
> > > mostly for more advanced features like XSL
> > > stylesheet
> > > and transformation (except for the example
> > > SimpleXPathAPI). Is there any other sample code
> > > available that I can look at?
> > > 
> > > I could write the function for getting an
> attribute
> > > value using the XPathEvaluator::evaluate()
> function.
> > > But while trying to set an attribute value, I am
> > > getting an exception. My code is as follows.
> > > 
> > > XalanNode* const	theResultNode =
> > > theEvaluator.selectSingleNode(theDOMSupport,
> > > theContextNode, XalanDOMString(buf).c_str(),
> > > thePrefixResolver);
> > > const XalanDOMString	valueXDS(value);
> > > if (theResultNode)
> > > 	((XalanAttr
> *)&theResultNode)->setValue(valueXDS);
> > > 
> > > Here setValue is cauing the exception.
> theResultNode
> > > is supposed to point to the attribute node whose
> > > value
> > > is getting set. Can somebody help me with this?
> Am I
> > > using the right classes and APIs?
> > > 
> > > Many thanks.
> > > 
> > > Pinaki
> > > 
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> > > protection around 
> > > http://mail.yahoo.com 
> > > 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> > http://mail.yahoo.com 
> > 
> 
> 
> ___________
> Sean Ryan
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: setting attribute in Xalan C++

Posted by Sean <sr...@yahoo.co.uk>.
Hello,

it sounds like all you need is an XML DOM, not an implementation of XSL.

You could just use Apache Xerces on its own - it has samples for creating XML elements.

Sean

--- pm <pi...@yahoo.com> wrote:

> Hi, I am still waiting for an answer on this. Can
> somebody please help! I noticed that the setValue or
> setNodeValue functions in XalanSourceTreeAttr class
> are written to just throw an exception and there is no
> other functionality. In fact, this is the case with
> all the 'set' functions in this class or even other
> classes like XalanSourceTreeElement. Does this mean
> that none of these functionalities are implemented in
> the Xalan library and the user needs to rewrite these
> functions to get the desired functionality?
> 
> Please help. Any help will be greatly appreciated.
> 
> Thank you.
> 
> - Pinaki
> 
> 
> --- pm <pi...@yahoo.com> wrote:
> 
> > Hi,
> > 
> > I have a question on Xalan C++. I am trying to
> > perform
> > very basic XML operations like
> > getting/setting/adding/removing attributes and
> > elements in a DOM tree. My code needs to use the
> > XPath
> > passed by the user to perform these operations. I
> > found that the sample code available on the website
> > is
> > mostly for more advanced features like XSL
> > stylesheet
> > and transformation (except for the example
> > SimpleXPathAPI). Is there any other sample code
> > available that I can look at?
> > 
> > I could write the function for getting an attribute
> > value using the XPathEvaluator::evaluate() function.
> > But while trying to set an attribute value, I am
> > getting an exception. My code is as follows.
> > 
> > XalanNode* const	theResultNode =
> > theEvaluator.selectSingleNode(theDOMSupport,
> > theContextNode, XalanDOMString(buf).c_str(),
> > thePrefixResolver);
> > const XalanDOMString	valueXDS(value);
> > if (theResultNode)
> > 	((XalanAttr *)&theResultNode)->setValue(valueXDS);
> > 
> > Here setValue is cauing the exception. theResultNode
> > is supposed to point to the attribute node whose
> > value
> > is getting set. Can somebody help me with this? Am I
> > using the right classes and APIs?
> > 
> > Many thanks.
> > 
> > Pinaki
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> > protection around 
> > http://mail.yahoo.com 
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 


___________
Sean Ryan

Re: setting attribute in Xalan C++

Posted by pm <pi...@yahoo.com>.
Hi, I am still waiting for an answer on this. Can
somebody please help! I noticed that the setValue or
setNodeValue functions in XalanSourceTreeAttr class
are written to just throw an exception and there is no
other functionality. In fact, this is the case with
all the 'set' functions in this class or even other
classes like XalanSourceTreeElement. Does this mean
that none of these functionalities are implemented in
the Xalan library and the user needs to rewrite these
functions to get the desired functionality?

Please help. Any help will be greatly appreciated.

Thank you.

- Pinaki


--- pm <pi...@yahoo.com> wrote:

> Hi,
> 
> I have a question on Xalan C++. I am trying to
> perform
> very basic XML operations like
> getting/setting/adding/removing attributes and
> elements in a DOM tree. My code needs to use the
> XPath
> passed by the user to perform these operations. I
> found that the sample code available on the website
> is
> mostly for more advanced features like XSL
> stylesheet
> and transformation (except for the example
> SimpleXPathAPI). Is there any other sample code
> available that I can look at?
> 
> I could write the function for getting an attribute
> value using the XPathEvaluator::evaluate() function.
> But while trying to set an attribute value, I am
> getting an exception. My code is as follows.
> 
> XalanNode* const	theResultNode =
> theEvaluator.selectSingleNode(theDOMSupport,
> theContextNode, XalanDOMString(buf).c_str(),
> thePrefixResolver);
> const XalanDOMString	valueXDS(value);
> if (theResultNode)
> 	((XalanAttr *)&theResultNode)->setValue(valueXDS);
> 
> Here setValue is cauing the exception. theResultNode
> is supposed to point to the attribute node whose
> value
> is getting set. Can somebody help me with this? Am I
> using the right classes and APIs?
> 
> Many thanks.
> 
> Pinaki
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com