Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Using XSLT to change XML and modify node with XPath

From: "Michael Kay" <mike@------------>
To:
Date: 2/6/2009 10:59:00 AM
Standard XSLT does not provide any way to evaluate an XPath expression that
is read dynamically from a source document as a string value. However, this
facility is often provided as an extension: see for example saxon:evaluate()
and saxon:evaluate-node().

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: kheris [mailto:kheris@xxxxx] 
> Sent: 05 February 2009 19:51
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Using XSLT to change XML and modify node with XPath
> 
> Hi all,
> 
> Maybe anyone can still help me on this:
> I need to transform XML1 to XML2.
> The procedure i am looking for is something like:
> 1) i reach the node var-path
> 2) i meet the node path. I get the value, and i search for 
> /def[name=value]
> 3) i meet the second node path in current var-path. I get the 
> value, and now i search for 
> /def[name=value_of_path_before]//def[value_of_path_now]
> 4) etc.
> 
> So, i use previously found node as starting node now. What is 
> more, i need to use //, as structure of path can be deeper 
> then explicitly said. But i can return only first found node 
> (so, if more nodes satisfy that, i get always the first one).
> 
> I have XQuery for searching/modifying nodes. Maybe is it 
> possible to combine it (i tried to google some more info, but 
> most tool don't allow that)
> 
> 
> XML 1:
> <?xml version="1.0" encoding="UTF-8"?>
> <xml>
>  <def>
>     <name>Var1</name>
>     <val>0</val>
>         <def>
>         <name>SubVar</name>
>         <val>012</val>
>     </def>
>  </def>
>  <def>
>     <name>Var2</name>
>     <val>1</val>
>  </def>
>  <test-node>
>         <use>
>             <var-path>
>                 <path>Var1</path>
>                 <path>SubVar</path>
>             </var-path>
>         </use>
>  </test-node>
> </xml>
> 
> XML 2:
> <?xml version="1.0" encoding="UTF-8"?>
> <xml>
>  <def>
>     <name>Var1</name>
>     <val>0</val>
>         <def>
>         <name>SubVar</name>
>         <val>012</val>
>     </def>
>  </def>
>  <def>
>     <name>Var2</name>
>     <val>1</val>
>  </def>
>  <test-node>
>         <use>
>             <var-path>
>                 <path value="0">Var1</path>
>                 <path value="012">SubVar</path>
>             </var-path>
>         </use>
>  </test-node>
> </xml>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent