[xquery-talk] XML to TEXT OUTPUT with xQUERY

Julio de la Vega j.vega at helpprintsolutions.com
Tue Dec 7 10:29:57 PST 2010


Hi *,

I have modified my xQuery and I am close to get what I need but I still have
a problem. My engine only returns the information from the first metadata.
Any idea?  I think it can be a bug of the engine because I d o not see any
issue in my development, in fact if I run it under a different xQuery
engine, it works. Do you have a different alternative to my development to
see if it works under my engine?

Thanks in advance

Regards


xQuery:

for $metadata  in //MetaData
return
string-join(($metadata/Partition/Attr[@name=
'partitionMetaDataFile']/@value,
                       $metadata/Partition/Attr[@name=
'CurrentPackageInPartition']/@value,
                      $metadata/Partition/Attr[@name=
'TotalPagesInPartition']/@value, '
'), ' ')
         


Output:

D:\GBPXI\OUT\Print\Extractos\00229-X-00000005_20101108082610_F1_XIGRUPO_1011
04.afp.xml 15346 7673







Julio de la Vega Pozo
Consultor Senior
j.vega at helpprintsolutions.com
Avda. General Perón, 32 7º G  28020 Madrid  tel: +34 91 598 0533
<http://www.plaxo.com/click_to_call?src=jj_signature&To=%2B34+91+598+0533&Em
ail=h.kuperman at helpprintsolutions.com>  fax: +34 91 598 0694 

www.helpprintsolutions.com <http://www.helpprintsolutions.com/> 

Este correo electrónico contiene información privada y confidencial. Si
usted no es el destinatario del mensaje no está autorizado a leerlo,
copiarlo o difundirlo. Si lo ha recibido por error, por favor contacte con
el remitente y destruya su contenido. Privileged/confidential information
may be contained in this e-mail. Any reading, copying o dissemination of
this communication by persons or entities other than its intended recipient
is prohibited. If you received this in error, please contact the sender and
delete it.


_____________________________________________
De: Julio de la Vega [mailto:j.vega at helpprintsolutions.com] 
Enviado el: viernes, 03 de diciembre de 2010 19:40
Para: 'Andrew Welch'; 'Michael Kay'
CC: 'talk at x-query.com'
Asunto: RE: [xquery-talk] XML to TEXT OUTPUT with xQUERY


Hi *,

I send an example of the input file. For every metadata node I need to
generate a line of information in a flat file. I have had different results
using the same xquery with different xquery engines.

Michale, for example with saxonHE I do not get any output if I use
!method=text.


The information that I need to get comes from "value" attributes.

Thank you

Regards




The output that I need to generate:

D:\GBPXI\OUT\Print\Extractos\00229-X-00000005_20101108082610_F1_XIGRUPO_1011
04.afp.xml 15346 7673
D:\GBPXI\OUT\Print\Extractos\00229-Y-00000005_20101108082610_F1_XIGRUPO_1011
04.afp.xml 25567 3444




Example of input file:

<root>
<MetaData>
   <Partition>
      <!-- Partition Level Attributes -->
      <Attr name="PartitionNO" value="1" />
      <Attr name="TotalPagesInPartition" value="15346" />
      <Attr name="TotalRectoPagesInPartition" value="7673" />
      <Attr name="TotalVersoPagesInPartition" value="7673" />
      <Attr name="TotalBlankPagesInsertedInPartition" value="1487" />
      <Attr name="TotalSheetsInPartition" value="7673" />
      <Attr name="CurrentPackageInPartition" value="5705" />
      <Attr name="partitionMetaDataFile"
value="D:\GBPXI\OUT\Print\Extractos\00229-X-00000005_20101108082610_F1_XIGRU
PO_101104.afp.xml" />
   </Partition>
   <!-- Stream Level Attributes -->
   <Attr name="TotalPagesInStream" value="15346" />
   <Attr name="TotalSheetsInStream" value="7673" />
   <Attr name="TotalBlankPagesInsertedInStream" value="1487" />
   <Attr name="TotalPartitionsInStream" value="1" />
</MetaData>
<MetaData >
   <Partition>
      <!-- Partition Level Attributes -->
      <Attr name="PartitionNO" value="1" />
      <Attr name="TotalPagesInPartition" value="25567" />
      <Attr name="TotalRectoPagesInPartition" value="3444" />
      <Attr name="TotalVersoPagesInPartition" value="3444" />
      <Attr name="TotalBlankPagesInsertedInPartition" value="1487" />
      <Attr name="TotalSheetsInPartition" value="7673" />
      <Attr name="CurrentPackageInPartition" value="5705" />
      <Attr name="partitionMetaDataFile"
value="D:\GBPXI\OUT\Print\Extractos\00229-Y-00000005_20101108082610_F1_XIGRU
PO_101104.afp.xml" />
   </Partition>
   <!-- Stream Level Attributes -->
   <Attr name="TotalPagesInStream" value="15346" />
   <Attr name="TotalSheetsInStream" value="7673" />
   <Attr name="TotalBlankPagesInsertedInStream" value="1487" />
   <Attr name="TotalPartitionsInStream" value="1" />
</MetaData>
</root>


Julio de la Vega Pozo
Consultor Senior
j.vega at helpprintsolutions.com
Avda. General Perón, 32 7º G  28020 Madrid  tel: +34 91 598 0533 fax: +34 91
598 0694 

www.helpprintsolutions.com

Este correo electrónico contiene información privada y confidencial. Si
usted no es el destinatario del mensaje no está autorizado a leerlo,
copiarlo o difundirlo. Si lo ha recibido por error, por favor contacte con
el remitente y destruya su contenido. Privileged/confidential information
may be contained in this e-mail. Any reading, copying o dissemination of
this communication by persons or entities other than its intended recipient
is prohibited. If you received this in error, please contact the sender and
delete it.


-----Mensaje original-----
De: Andrew Welch [mailto:andrew.j.welch at gmail.com] 
Enviado el: viernes, 03 de diciembre de 2010 11:47
Para: Julio de la Vega
CC: talk at x-query.com
Asunto: Re: [xquery-talk] XML to TEXT OUTPUT with xQUERY

It's fine to do this with xquery, but you need to post back a small
complete sample input and required output...


On 3 December 2010 09:20, Julio de la Vega
<j.vega at helpprintsolutions.com> wrote:
>
>
> Hi *,
>
>
>
> I need to process and xml file with xQuery and generate a text file with
the
> result of my xquery. In my tests I have several issues:
>
>
>
> -          Do I have to do it with string function or is there other
option?
>
> -          I need to give an specific format to the output but I cannot
> control line feeds. Is it possible to insert  line feed with any command?
>
> -          Do we have to use xslt instead of xquery? Is there any option
to
> do it with xquery?
>
>
>
>
>
> Little example ot the actual development:
>
>
>
> for $metadata  in doc('Estadisticas')/MetaData
>
> return
>
> (
>
> string($metadata/Partition/Attr[@name=
'CurrentPackageInPartition']/@value),
>
>
>
> string($metadata/Partition/Attr[@name= 'TotalPagesinDocument']/@value),
>
> )
>
>
>
> Thanks in advance
>
>
>
> Regards
>
>
>
>
>
> Julio de la Vega Pozo
> Consultor Senior
> j.vega at helpprintsolutions.com
>
> Avda. General Perón, 32 7º G  28020 Madrid  tel: +34 91 598 0533 fax: +34
91
> 598 0694
>
>
>
> www.helpprintsolutions.com
>
>
>
> Este correo electrónico contiene información privada y confidencial. Si
> usted no es el destinatario del mensaje no está autorizado a leerlo,
> copiarlo o difundirlo. Si lo ha recibido por error, por favor contacte con
> el remitente y destruya su contenido. Privileged/confidential information
> may be contained in this e-mail. Any reading, copying o dissemination of
> this communication by persons or entities other than its intended
recipient
> is prohibited. If you received this in error, please contact the sender
and
> delete it.
>
>
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>



-- 
Andrew Welch
http://andrewjwelch.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20101207/a671dd6b/attachment-0001.htm


More information about the talk mailing list