[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XML Update HOW TO?

Subject: XML Update HOW TO?
From: Cristobal Galiano Fernandez <c.galiano@xxxxx>
Date: Fri, 12 Jan 2001 15:40:11 +0100
xml update value
Hi everybody!

I wish update an XML file:

The node Paginas/Pagina[Tipo=New] must update Paginas/Pagina[Tipo=Old]
by unique ID.


<?xml version='1.0' encoding='ISO-8859-1'?>
<Paginas>
   <Pagina Id="Id1" Tipo="New">
      <texto ID='Etiqueta12' type='104'>AMod</texto>
      <texto ID='Etiqueta6' fuente='F2'>SIGNOMod</texto>
      <texto ID='ClOpe' >241</texto>
   </Pagina>
   <Pagina Id="Id1" Tipo="Old">
      <texto ID='Etiqueta12' type='100' fuente='F1' size='16' x = '211'
y = '690' x1='25' y1='19' modo='0'>A</texto>
      <texto ID='Etiqueta9' type='100' fuente='F1' size='8' x = '483' y
= '744' x1='54' y1='11' modo='0'>CL. OPERAC.</texto>
      <texto ID='Etiqueta6' type='100' fuente='F1' size='8' x = '483' y
= '727' x1='30' y1='11' modo='0'>SIGNO</texto>
      <texto ID='Etiqueta4' type='100' fuente='F1' size='8' x = '483' y
= '758' x1='16' y1='11' modo='0'>Ref</texto>
      <texto ID='Etiqueta3' type='100' fuente='F1' size='16' x = '231' y
= '755' x1='15' y1='21' modo='0'>D</texto>
      <texto ID='Etiqueta2' type='100' fuente='F1' size='16' x = '200' y
= '752' x1='25' y1='19' modo='0'>A</texto>
      <cuadro ID='Cuadro10' type='101' x='202' y = '711' x1='133'
y1='42'/>
      <cuadro ID='Cuadro1' type='101' x='225' y = '762' x1='29'
y1='20'/>
      <cuadro ID='Cuadro0' type='101' x='197' y = '762' x1='29'
y1='20'/>
      <linea1 ID='Línea11' type='102' x='242' y = '712' x1='0' y1='0'/>
      <texto ID='ClOpe' type='109' fuente='F1' size='8' x = '540' y =
'744' x1='85' y1='12' modo='0'>240</texto>
   </Pagina>
</Paginas>

The XSL constructed must done an output as

<Paginas>
   <Pagina Id="Id1" Tipo="Old">
      <texto ID='Etiqueta12' type='104' fuente='F1' size='16' x = '211'
y = '690' x1='25' y1='19' modo='0'>AMod</texto>
      <texto ID='Etiqueta9' type='100' fuente='F1' size='8' x = '483' y
= '744' x1='54' y1='11' modo='0'>CL. OPERAC.</texto>
      <texto ID='Etiqueta6' type='100' fuente='F2' size='8' x = '483' y
= '727' x1='30' y1='11' modo='0'>SIGNOMod</texto>
      <texto ID='Etiqueta4' type='100' fuente='F1' size='8' x = '483' y
= '758' x1='16' y1='11' modo='0'>Ref</texto>
      <texto ID='Etiqueta3' type='100' fuente='F1' size='16' x = '231' y
= '755' x1='15' y1='21' modo='0'>D</texto>
      <texto ID='Etiqueta2' type='100' fuente='F1' size='16' x = '200' y
= '752' x1='25' y1='19' modo='0'>A</texto>
      <cuadro ID='Cuadro10' type='101' x='202' y = '711' x1='133'
y1='42'/>
      <cuadro ID='Cuadro1' type='101' x='225' y = '762' x1='29'
y1='20'/>
      <cuadro ID='Cuadro0' type='101' x='197' y = '762' x1='29'
y1='20'/>
      <linea1 ID='Línea11' type='102' x='242' y = '712' x1='0' y1='0'/>
      <texto ID='ClOpe' type='109' fuente='F1' size='8' x = '540' y =
'744' x1='85' y1='12' modo='0'>241</texto>
   </Pagina>
</Paginas>

A first tentative was:

<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:output method="xml" indent="yes"/>

   <xsl:template match="/">

      <xsl:apply-templates select="//Pagina[@Tipo='Old']" />
   </xsl:template>

   <xsl:template match="Pagina">

        <xsl:call-template name="Copia" />
  </xsl:template>

   <xsl:template name="Copia">
      <H1>Hola</H1>
       <xsl:for-each select="node()"> <!-- Para cada nodo -->

         <!--  [<xsl:value-of
select="/Paginas/Pagina[@Tipo='New']/[name()=current()]" />] -->

           <xsl:variable name="W">
                  <xsl:value-of
select="concat('Paginas/Pagina[@Tipo='New']/','')" />
                  <xsl:value-of select="concat('texto','')" />
                  <xsl:text>[@ID='Etiqueta12']</xsl:text>
           </xsl:variable>
           (<xsl:value-of select="$W" />)
           <xsl:variable name="W1">
                 <xsl:copy-of select="$W" />
           </xsl:variable>
            [<xsl:value-of select="$W1" />]
          <!--  <xsl:variable name="New"
select="/Paginas/Pagina[@Tipo='New']/texto[@ID='Etiqueta12']" /> -->
          <!--    <xsl:variable name="New" select="$W" /> -->
          <!--  (<xsl:value-of select="$New" />) -->
            <!-- <xsl:value-of select="name()" /> -->
            </xsl:for-each>

   <!--    <xsl:copy-of select="." /> -->
   </xsl:template>

</xsl:stylesheet>

but my problem is that <xsl:value-of select="$W" /> return the string
Paginas/Pagina[@Tipo=]/texto[@ID='Etiqueta12'] not the node-set

Can any help me

Thanks in advance

Cristóbal G.F.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.