Using flex create a program to process an XML document
Budget: €30 – €250 EUR
Using flex create a program to process an XML document
performing the necessary operations so that at the end of the
processed allows the following statistics to be displayed:
- the number of comments.
- the number of empty elements (end without having tags
nested or text inside).
- the name of the tag that contains more attributes and its number.
- the namespace with the longest value and its associated prefix,
if you have it.
The contents of the CDATA sections should be ignored for all
the statistics.
For example, con una entrada como la siguiente:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE eje PUBLIC "-//cgosorio//DTD eje//ES"
"http://www.ubu.es/DTD/eje.dtd" >
<!-- lo de arriba lo procesa sin contar -->
<eje>
<etiq1 atr1="v1" atr2='val2' atr3="val3">
texto y mas texto
</etiq1> <!-- una etiqueta de cierre-->
y mira que bueno, incluso mas texto
<!-- esto es un comentario -->
<etiqueta2/><!-- un elemento vacío -->
<!-- esto lo voy a contar como una de inicio y una de cierre -->
<ns1:etiq2 xmlns:ns1="http://pisuerga.inf.ubu.es/" at2="val2" at3="val3"></ns1:etiq2>
<![CDATA[
<etiq2 > <!-- esta etiqueta y este comentario no los voy a contar
por estar dentro de una sección CDATA -->
]]>
</eje>
should give:
- Comments: 5
- Empty elements: 2
- The label "etiq1" is the one with the most attributes inside: 3.
- The longest namespace value is "http://pisuerga.inf.ubu.es/"
and the associated prefix is "ns1".
It has to work for any xml file.
performing the necessary operations so that at the end of the
processed allows the following statistics to be displayed:
- the number of comments.
- the number of empty elements (end without having tags
nested or text inside).
- the name of the tag that contains more attributes and its number.
- the namespace with the longest value and its associated prefix,
if you have it.
The contents of the CDATA sections should be ignored for all
the statistics.
For example, con una entrada como la siguiente:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE eje PUBLIC "-//cgosorio//DTD eje//ES"
"http://www.ubu.es/DTD/eje.dtd" >
<!-- lo de arriba lo procesa sin contar -->
<eje>
<etiq1 atr1="v1" atr2='val2' atr3="val3">
texto y mas texto
</etiq1> <!-- una etiqueta de cierre-->
y mira que bueno, incluso mas texto
<!-- esto es un comentario -->
<etiqueta2/><!-- un elemento vacío -->
<!-- esto lo voy a contar como una de inicio y una de cierre -->
<ns1:etiq2 xmlns:ns1="http://pisuerga.inf.ubu.es/" at2="val2" at3="val3"></ns1:etiq2>
<![CDATA[
<etiq2 > <!-- esta etiqueta y este comentario no los voy a contar
por estar dentro de una sección CDATA -->
]]>
</eje>
should give:
- Comments: 5
- Empty elements: 2
- The label "etiq1" is the one with the most attributes inside: 3.
- The longest namespace value is "http://pisuerga.inf.ubu.es/"
and the associated prefix is "ns1".
It has to work for any xml file.