Altova Mailing List Archives


[xsl] Converting SSI variables to XML

From: "tom tom" <tomxsllist@----------->
To:
Date: 9/11/2006 3:31:00 PM
Hi all, I wish to turn the following CDATA input:



<xml>



   <![CDATA[



<!--#set var="t.news.1.title" value="This is the title"-->
<!--#set var="t.news.1.image_small" value="smallimage"-->
<!--#set var="t.news.1.image_large" value="largeimage"-->

<!--#set var="t.news.2.title" value=""-->
<!--#set var="t.news.2.image_small" value=""-->
<!--#set var="t.news.2.image_large" value=""-->

<!--#set var="t.news.3.title" value=""-->
<!--#set var="t.news.3.image_small" value=""-->
<!--#set var="t.news.3.image_large" value=""-->


]]>
   </xml>


Into XML as follows using XSLT 2:



<ts>
 <group num="1">
  <var name="t.news.1.title" value="This is the title"/>
  <var name="t.news.1.image_small" value="smallimage"/>
  <var name="t.news.1.image_large" value="largeimage"/>
 </group>
 <group num="2">
  etc.....
 </group>
</ts>

I have used the analyze-string function to do a regex match on the HTML 
comments, it then extracts the values of 'var' and 'value' to create:



<ts>



  <var name="t.news.1.title" value="This is the title"/>
  <var name="t.news.1.image_small" value="smallimage"/>
  <var name="t.news.1.image_large" value="largeimage"/>


  etc.....



</ts>



To add the grouping I will need to do another pass over this data however I 
am finding it complex to extract the numerical data from the string at @name 
and it seems unnecessary complex. I have also tried nesting 
xsl:analyze-string elements to create a group first then the individual 
variables. Can anyone recommend the correct way to do this?



Thanks in advance



Tom



_________________________________________________________________

Download the new Windows Live Toolbar, including Desktop search! 
http://toolbar.live.com/?mkt=en-gb

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.