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 Bettina Reck <Be...@gmx.de> on 2004/10/13 13:34:28 UTC
How to redirect the content of xsl:message element to a file?
Hi all,
is there a possibility to redirect a text message from the element
xsl:message to a file instead of stderr? I validated an xml file against a
W3C Schema and afterwards in order to do additional checking against a
stylesheet. The validation errors from the Xerces parser are written to a
file (by use of a derived class of the DefaultHandler) and I would like to
append the error messages which I defined in the stylesheet between the
<xsl:message> tags to the already created file.
Is there a class for Xalan to register with the XalanTransformer similar to
the behaviour of the DefaultHandler class?
I searched the docs and the archive for any examples but I still have no
clue how to start.
Any hints are appreciated!
Thanks,
Bettina
--
GMX ProMail mit bestem Virenschutz http://www.gmx.net/de/go/mail
+++ Empfehlung der Redaktion +++ Internet Professionell 10/04 +++
Re: How to redirect the content of xsl:message element to a file?
Posted by da...@us.ibm.com.
> Hi Dave,
>
> thank you for your answer! In the meantime I tried both versions:
> XalanTranformer::setWarningStream() worked fine, but finally I will need
a
> ProblemListener. Therefore I derived a class from the
> XalanTransformerProblemListener and reimplemented the problem() method –
at
> least I tried to do so. To get information from the input parameter I
> searched for a while how to convert a XalanDOMString and a XalanDOMChar
to a
> std::string.
> Now there is another question:
> my application ends up in the catch block I enclosed the
transform()-method
> of the XalanTransformer in caused by an assignment from XalanDOMChar to
> XalanDOMString (as I found out):
>
> XalanDOMString& dom_str_uri = dom_str_uri.assign(_uri);
This code is puzzling. Is dom_str_uri really a reference to itself? Or
is this a typo?
>
> Where _uri is the input parameter from the problem() function of the
derived
> ProblemListener class. But I simply have no clue why it does so. Do I
use
> the wrong function?
You should set your debugger to stop when an exception is thrown, but I
suspect either your code is broken, as I mentioned above, or the _uri
parameter is null, and you are not checking for that before you call
XalanDOMString::assign().
Dave
Re: How to redirect the content of xsl:message element to a file?
Posted by Bettina Reck <Be...@gmx.de>.
Hi Dave,
thank you for your answer! In the meantime I tried both versions:
XalanTranformer::setWarningStream() worked fine, but finally I will need a
ProblemListener. Therefore I derived a class from the
XalanTransformerProblemListener and reimplemented the problem() method at
least I tried to do so. To get information from the input parameter I
searched for a while how to convert a XalanDOMString and a XalanDOMChar to a
std::string.
Now there is another question:
my application ends up in the catch block I enclosed the transform()-method
of the XalanTransformer in caused by an assignment from XalanDOMChar to
XalanDOMString (as I found out):
XalanDOMString& dom_str_uri = dom_str_uri.assign(_uri);
Where _uri is the input parameter from the problem() function of the derived
ProblemListener class. But I simply have no clue why it does so. Do I use
the wrong function?
Thanks again for any help!
Bettina
> > is there a possibility to redirect a text message
> > from the element xsl:message to a file instead of
> > stderr? I validated an xml file against a W3C Schema
> > and afterwards â in order to do additional checking
> > â against a stylesheet. The validation errors from
> > the Xerces parser are written to a file (by use of
> > a derived class of the DefaultHandler) and I would
> > like to append the error messages which I defined in
> > the stylesheet between the <xsl:message> tags to the
> > already created file. Is there a class for Xalan to
> > register with the XalanTransformer similar to the
> > behaviour of the DefaultHandler class?
>
> If you set your own derivative of ProblemListener, using
> XalanTransformer::setProblemListener(), you can re-direct messages,
> warnings, and errors. However, you will be responsible for the display of
> any diagnostic output if you do this.
>
> If you just want simple re-direction of warnings and messages, you can set
> and instance of std::ostream, by calling
> XalanTranformer::setWarningStream(). Again, this interrupts the normal
> display of diagnostic output (except errors), so you will be responsible
> for displaying messages or warnings.
>
> Dave
--
GMX ProMail mit bestem Virenschutz http://www.gmx.net/de/go/mail
+++ Empfehlung der Redaktion +++ Internet Professionell 10/04 +++
Re: How to redirect the content of xsl:message element to a file?
Posted by da...@us.ibm.com.
> is there a possibility to redirect a text message
> from the element xsl:message to a file instead of
> stderr? I validated an xml file against a W3C Schema
> and afterwards – in order to do additional checking
> – against a stylesheet. The validation errors from
> the Xerces parser are written to a file (by use of
> a derived class of the DefaultHandler) and I would
> like to append the error messages which I defined in
> the stylesheet between the <xsl:message> tags to the
> already created file. Is there a class for Xalan to
> register with the XalanTransformer similar to the
> behaviour of the DefaultHandler class?
If you set your own derivative of ProblemListener, using
XalanTransformer::setProblemListener(), you can re-direct messages,
warnings, and errors. However, you will be responsible for the display of
any diagnostic output if you do this.
If you just want simple re-direction of warnings and messages, you can set
and instance of std::ostream, by calling
XalanTranformer::setWarningStream(). Again, this interrupts the normal
display of diagnostic output (except errors), so you will be responsible
for displaying messages or warnings.
Dave