xsl-list
[Top] [All Lists]

Re: [xsl] XML transformation based on parameters

2009-04-14 11:00:47
Martin,

thanks a lot!!  Making one small change to your code I obtained what I
wanted to do.
Now, I should apply 2 external parameters to this code (p and v):

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

<xsl:param name="p" select="id" />
<xsl:param name="v" select="newvalue" />

<xsl:template match="@* | node()">
 <xsl:copy>
   <xsl:apply-templates select="@* | node()"/>
 </xsl:copy>
</xsl:template>

<xsl:template match="param[(_at_)name=' { $p } ']">
 <xsl:text>{ $v }</xsl:text>
</xsl:template>

<xsl:template match="param">
 <xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>

but it doesn't work! What other am I missing?

Vasu, this my question should answer to your one! :)

Thanks again!!!!
e.


2009/4/14 Vasu Chakkera <vasucv(_at_)gmail(_dot_)com>:
        <Catalog>
           <Id> newvalue </Id>
        </Catalog>

where will you get this "newvalue" from ? Presumably it wont be in the
XML.. or will it?
Vasu

2009/4/14 Emiliano Pecis <emiliano(_dot_)pecis(_at_)gmail(_dot_)com>:
Hi All,

I'm using latest version of Stylus Studio, to develop a XSLT (based on
Saxon 9.0.1.5 processor) to do the following simple (should be)
transformation.

From XML:

<GetCatalog>
   <ListOfCatalog>
        <Catalog>
           <Id> <param name="same/new">foo</param> </Id>
        </Catalog>
   </ListOfCatalog>
</GetCatalog>

The destination must depends on "name" attribute of param element. If
name="same" the following XML must be returned:

<GetCatalog>
   <ListOfCatalog>
        <Catalog>
           <Id> foo </Id>
        </Catalog>
   </ListOfCatalog>
</GetCatalog>

Otherwise:

<GetCatalog>
   <ListOfCatalog>
        <Catalog>
           <Id> newvalue </Id>
        </Catalog>
   </ListOfCatalog>
</GetCatalog>

In both cases <param> element has to be removed.

Now, I have two issues. First of all the management of this
"parameters".Secondly, every xml elements (GetCatalog, ListOfCatalog,
etc etc) could change: only tag "param" will be the same.

Thanks a lot in advance,
emiliano

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--
Vasu Chakkera
Numerical Algorithms Group Ltd.
Oxford
www.vasucv.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--