[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re : [scew-users] scew_element_by_name error..
From: |
mach |
Subject: |
Re : [scew-users] scew_element_by_name error.. |
Date: |
Thu, 15 Jul 2010 00:59:45 -0700 (PDT) |
Thank you Aleix,
The reason I used assertion was just for check the return value of element
if found.
As you wrote, it's OK to use if statement.
The original examples/scew_print/scew_print.c without any modification prints
well
input xml files as following.
...
<trt:Profiles token="1080P_h264">
...
...
...
</trt:Profiles>
...
So, there is trt:Profiles in input xml file.
And I just added some code among the scew_print.c like this...
tree = scew_parser_load (parser, reader);
if (tree == NULL)
{
scew_error code = scew_error_code ();
scew_printf (_XT("Unable to parse file (error #%d: %s)\n"),
code, scew_error_string (code));
if (code == scew_error_expat)
{
enum XML_Error expat_code = scew_error_expat_code (parser);
scew_printf (_XT("Expat error #%d (line %d, column %d): %s\n"),
expat_code,
scew_error_expat_line (parser),
scew_error_expat_column (parser),
scew_error_expat_string (expat_code));
}
/* Frees the SCEW parser and reader. */
scew_reader_free (reader);
scew_parser_free (parser);
return EXIT_FAILURE;
}
#if 0
{
scew_element *element = NULL;
scew_element *root = NULL;
root = scew_tree_root (tree);
assert(root != NULL);
element = scew_element_by_name(root, _XT("trt:Profiles"));
assert(element != NULL);
}
#endif
/* Prints full tree. */
// scew_printf (_XT("\n*** Manual print:\n\n"));
print_element (scew_tree_root (tree), 0);
/* Prints full tree using SCEW writer. */
scew_printf (_XT("\n\n*** SCEW writer (stdout) print:\n\n"));
writer = scew_writer_fp_create (stdout);
printer = scew_printer_create (writer);
scew_printer_print_tree (printer, tree);
scew_printf (_XT("\n"));
Should I have to use some initialization functions...??
Thanks,
Best regards,
Mach
----- 메시지 원본 ----
보낸 사람: Aleix Conchillo Flaqué <address@hidden>
받는 사람: mach <address@hidden>
보낸 시간: 2010년 7월 15일 (목), 3:59:53 PM
제목: Re: [scew-users] scew_element_by_name error..
On Thu, Jul 15, 2010 at 04:07, mach <address@hidden> wrote:
> Hello Dear;
>
> I am testing the api of scew-1.1.2 as below using
> example/scew_print/scew_print.c.
> The example works fine without appended part.
> But scew_print abort with a message like below혻when compiled with appeded
part.
>
> lt-scew_print: scew_print.c:189: main: Assertion `element != ((void *)0)'
> failed.
> Aborted
>
> Could you let me know what is wrong or missed.
>
scew_element_by_name returns an element if it finds it, otherwise it
returns NULL. So, you should not use an assertion, use an "if"
instead.
> lt-scew_print: scew_print.c:189: main: Assertion `element != ((void *)0)'
Again, this means your element "trt:Profiles" was not found.
Aleix