473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Replacing dummy attribute with string of xml

7
Very new to XML/XSL, so please forgive me if this is an incredibly simple question. I've been pulling my hair out over this for several days now.

I'm working on an internal application that takes the output from a custom Excel spreadsheet, and creates a Final Cut Pro sequence in XML. Due to the way Excel handles nested repeating elements, I need to find a way to replace a dummy element I have created with a whole series of repeating elements. I could use a simple find and replace text editor method, but I would prefer to take care of everything in the xslt transform if possible. Any ideas?

Thanks!


My existing XSL (which just strips out the empty tags) is posted at the bottom.

The code is as follows.

Expand|Select|Wrap|Line Numbers
  1. <effect>
  2.     <name>Text</name>
  3.     <effectid>Text</effectid>
  4.     <effectcategory>Text</effectcategory>
  5.     <effecttype>generator</effecttype>
  6.     <mediatype>video</mediatype>
  7.     <parameter>
  8.               <parameterid>str</parameterid>
  9.           <name>Text</name>
  10.           <value>Tuesday at 10:00</value>
  11.     </parameter>
  12.     <dummyattr>replace_me</dummyattr>
  13. </effect>
  14.  
I need to replace <dummyattr>replace_me</dummyattr>
with the following (these are not variables, elements and data will always be the same):


Expand|Select|Wrap|Line Numbers
  1. <parameter>
  2.       <parameterid>fontname</parameterid>
  3.       <name>Font</name>
  4.       <value>ITC Officina Sans</value>
  5. </parameter>
  6. <parameter>
  7.       <parameterid>fontsize</parameterid>
  8.       <name>Size</name>
  9.       <value>39</value>
  10. </parameter>
  11. <parameter>
  12.       <parameterid>fontstyle</parameterid>
  13.       <name>Style</name>
  14.       <value>1</value>
  15.       </parameter>
  16. <parameter>
  17.       <parameterid>fontalign</parameterid>
  18.       <name>Alignment</name>
  19.       <value>1</value>
  20. </parameter>
  21. <parameter>
  22.       <parameterid>fontcolor</parameterid>
  23.       <name>Font Color</name>
  24.       <value>
  25.             <alpha>255</alpha>
  26.         <red>1</red>
  27.             <green>2</green>
  28.             <blue>3</blue>
  29.       </value>
  30. </parameter>
  31. <parameter>
  32.       <parameterid>origin</parameterid>
  33.       <name>Origin</name>
  34.       <value>
  35.             <horiz>-0.101389</horiz>
  36.             <vert>0.383604</vert>
  37.       </value>
  38. </parameter>

Existing XSL:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    
  3.     <xsl:output method="xml" indent="yes"/>    
  4.     <xsl:strip-space elements="*"/>    
  5.     <xsl:template match="node()//*">        
  6.         <xsl:if test="normalize-space(.)">            
  7.             <xsl:copy>                
  8.                 <xsl:apply-templates select="@*|node()"/>            
  9.             </xsl:copy>        
  10.         </xsl:if>    
  11.     </xsl:template>    
  12.     <xsl:template match="@*|node()">        
  13.         <xsl:copy>            
  14.             <xsl:apply-templates select="@*|node()"/>        
  15.         </xsl:copy>    
  16.     </xsl:template>
  17. </xsl:stylesheet>
Mar 15 '07 #1
13 2293
dorinbogdan
839 Expert 512MB
Welcome to TSDN...

I'm not sure what is the desired output.
Please post the final structure you expect to obtain too.
Mar 15 '07 #2
jtric
7
Welcome to TSDN...

I'm not sure what is the desired output.
Please post the final structure you expect to obtain too.
Thanks!

Sorry, here is the final structure:


Expand|Select|Wrap|Line Numbers
  1. <effect>
  2.     <name>Text</name>
  3.     <effectid>Text</effectid>
  4.     <effectcategory>Text</effectcategory>
  5.     <effecttype>generator</effecttype>
  6.     <mediatype>video</mediatype>
  7.     <parameter>
  8.               <parameterid>str</parameterid>
  9.           <name>Text</name>
  10.           <value>Tuesday at 10:00</value>
  11.     </parameter>
  12.     <parameter>
  13.                  <parameterid>fontname</parameterid>
  14.                  <name>Font</name>
  15.                  <value>ITC Officina Sans</value>
  16.         </parameter>
  17.         <parameter>
  18.                 <parameterid>fontsize</parameterid>
  19.                 <name>Size</name>
  20.                 <value>39</value>
  21.          </parameter>
  22.          <parameter>
  23.                <parameterid>fontstyle</parameterid>
  24.                <name>Style</name>
  25.                <value>1</value>
  26.          </parameter>
  27.          <parameter>
  28.               <parameterid>fontalign</parameterid>
  29.               <name>Alignment</name>
  30.               <value>1</value>
  31.          </parameter>
  32.          <parameter>
  33.               <parameterid>fontcolor</parameterid>
  34.               <name>Font Color</name>
  35.               <value>
  36.                   <alpha>255</alpha>
  37.               <red>1</red>
  38.                   <green>2</green>
  39.                   <blue>3</blue>
  40.               </value>
  41.          </parameter>
  42.          <parameter>
  43.              <parameterid>origin</parameterid>
  44.               <name>Origin</name>
  45.               <value>
  46.                     <horiz>-0.101389</horiz>
  47.                     <vert>0.383604</vert>
  48.               </value>
  49.           </parameter>
  50. </effect>
  51.  
Mar 15 '07 #3
dorinbogdan
839 Expert 512MB
So you will use 2 XML files to get the result.
Then you need a merge/concat method.
For the moment I only can point you to some links.
See if
Merge two files or
Merging XML Documents help.
Mar 15 '07 #4
jtric
7
So you will use 2 XML files to get the result.
Then you need a merge/concat method.
For the moment I only can point you to some links.
See if
Merge two files or
Merging XML Documents help.
Solution two in that link looks like exactly what I need. I will tool around with it.

Thanks for pointing me in the right direction! Will post my solution if I'm able to figure it out.
Mar 15 '07 #5
jtric
7
Solution two in that link looks like exactly what I need. I will tool around with it.

Thanks for pointing me in the right direction! Will post my solution if I'm able to figure it out.
Not sure who else might benefit from this, but I figured I would post what ended up working. Thanks again for pointing me in the right direction.

(I did not end up needing to use the dummy tag)

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    
  3.     <xsl:output method="xml" encoding="UTF-8" standalone="yes" indent="yes"/>    
  4.     <xsl:variable name="textinfo">        
  5.         <parameter>            
  6.             <parameterid>fontname</parameterid>            
  7.             <name>Font</name>            
  8.             <value>ITC Officina Sans</value>        
  9.         </parameter>        
  10.         <parameter>            
  11.             <parameterid>fontsize</parameterid>            
  12.             <name>Size</name>            
  13.             <value>39</value>        
  14.         </parameter>        
  15.         <parameter>            
  16.             <parameterid>fontstyle</parameterid>            
  17.             <name>Style</name>            
  18.             <value>1</value>        
  19.         </parameter>        
  20.         <parameter>            
  21.             <parameterid>fontalign</parameterid>            
  22.             <name>Alignment</name>            
  23.             <value>1</value>        
  24.         </parameter>        
  25.         <parameter>            
  26.             <parameterid>fontcolor</parameterid>            
  27.             <name>Font Color</name>            
  28.             <value>                
  29.                 <alpha>255</alpha>                
  30.                 <red>1</red>                
  31.                 <green>2</green>                
  32.                 <blue>3</blue>            
  33.             </value>        
  34.         </parameter>        
  35.         <parameter>            
  36.             <parameterid>origin</parameterid>            
  37.             <name>Origin</name>            
  38.             <value>                
  39.                 <horiz>-0.101389</horiz>                
  40.                 <vert>0.383604</vert>            
  41.             </value>        
  42.         </parameter>    
  43.     </xsl:variable>    
  44.     <xsl:strip-space elements="*"/>    
  45.     <xsl:template match="node()//*">        
  46.         <xsl:if test="normalize-space(.)">            
  47.             <xsl:copy>                
  48.                 <xsl:apply-templates select="@*|node()"/>            
  49.             </xsl:copy>        
  50.         </xsl:if>    
  51.     </xsl:template>    
  52.     <xsl:template match="//generatoritem/effect">    
  53.         <xsl:copy>    
  54.             <xsl:copy-of select="*"/> 
  55.             <xsl:copy-of select="$textinfo"/> 
  56.         </xsl:copy>    
  57.     </xsl:template>    
  58.     <xsl:template match="@*|node()">        
  59.         <xsl:copy>            
  60.             <xsl:apply-templates select="@*|node()"/>        
  61.         </xsl:copy>    
  62.     </xsl:template>
  63. </xsl:stylesheet>
Mar 16 '07 #6
dorinbogdan
839 Expert 512MB
Glad to see it is working.

Who knows, sometime it may be helpful for others too.
Mar 19 '07 #7
dorinbogdan
839 Expert 512MB
Since the problem was solved I'll close the thread.
Mar 21 '07 #8
dorinbogdan
839 Expert 512MB
I re-open the thread in order to allow further comments or suggestions from other members or experts, as per adim request.
Mar 22 '07 #9
jtric
7
I'm glad that you re-opened the thread, as I seem to have borked my solution by adding what I thought was a simple modification.

The structure I am working with is essentially this (simplified, but this is the section I need to modify):

Expand|Select|Wrap|Line Numbers
  1. <xmeml>
  2.    <sequence>
  3.        <media>
  4.           <video>
  5.              <track>
  6.                   <generatoritem id = "Text">
  7.                    <name>Text</name>
  8.                    <effect>
  9.                         <name>Text</name>
  10.                         <parameter>
  11.                               <parameterid>Text</parameterid>
  12.                          </parameter>
  13.                    </effect>
  14.                   </generatoritem>
  15.                </track>
  16.            <video>
  17.         <media>
  18.   <sequence>
  19. <xmeml>
I need to insert two sets of tags that are held in variables in my xsl.
One goes in generatoritem/effect
One goes in generatoritem


The previous posts illustrate how I accomplished the former. I added the following to the xslt to accomplish the latter, thinking I understood fully how it worked.

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="generatoritem[@id='Text']">        
  2.         <xsl:copy-of select="*"/>
  3.         <xsl:copy-of select="$dropshadow"/>
  4. </xsl:template>
However, when I add that, nothing gets added to generatoritem/effect and it seems that my generatoritem tags get stripped completely? Perhaps someone could point me in the right direction to fix this?

Thanks in advance for any guidance anyone can offer!

My full xsl is below:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    
  3.     <xsl:output method="xml" encoding="UTF-8" standalone="yes" indent="yes"/>    
  4.     <xsl:variable name="textinfo">        
  5.         <parameter>            
  6.             <parameterid>fontname</parameterid>            
  7.             <name>Font</name>            
  8.             <value>ITC Officina Sans</value>        
  9.         </parameter>        
  10.         <parameter>            
  11.             <parameterid>fontsize</parameterid>            
  12.             <name>Size</name>            
  13.             <value>39</value>        
  14.         </parameter>        
  15.         <parameter>            
  16.             <parameterid>fontstyle</parameterid>            
  17.             <name>Style</name>            
  18.             <value>1</value>        
  19.         </parameter>        
  20.         <parameter>            
  21.             <parameterid>fontalign</parameterid>            
  22.             <name>Alignment</name>            
  23.             <value>1</value>        
  24.         </parameter>        
  25.         <parameter>            
  26.             <parameterid>fontcolor</parameterid>            
  27.             <name>Font Color</name>            
  28.             <value>                
  29.                 <alpha>255</alpha>                
  30.                 <red>1</red>                
  31.                 <green>2</green>                
  32.                 <blue>3</blue>            
  33.             </value>        
  34.         </parameter>        
  35.         <parameter>            
  36.             <parameterid>origin</parameterid>            
  37.             <name>Origin</name>            
  38.             <value>                
  39.                 <horiz>-0.101389</horiz>                
  40.                 <vert>0.383604</vert>            
  41.             </value>        
  42.         </parameter>    
  43.     </xsl:variable>    
  44.     <xsl:variable name="dropshadow">        
  45.         <filter>            
  46.             <effect>                
  47.                 <name>Drop Shadow</name>                
  48.                 <effectid>dropshadow</effectid>                
  49.                 <effectcategory>motion</effectcategory>                
  50.                 <effecttype>motion</effecttype>                
  51.                 <mediatype>video</mediatype>                
  52.                 <parameter>                    
  53.                     <parameterid>offset</parameterid>                    
  54.                     <name>offset</name>                    
  55.                     <value>0</value>                
  56.                 </parameter>                
  57.                 <parameter>                    
  58.                     <parameterid>angle</parameterid>                    
  59.                     <name>angle</name>                    
  60.                     <value>135</value>                
  61.                 </parameter>                
  62.                 <parameter>                    
  63.                     <parameterid>color</parameterid>                    
  64.                     <name>color</name>                    
  65.                     <value>                        
  66.                         <alpha>0</alpha>                        
  67.                         <red>255</red>                        
  68.                         <green>255</green>                        
  69.                         <blue>255</blue>                    
  70.                     </value>                
  71.                 </parameter>                
  72.                 <parameter>                    
  73.                     <parameterid>softness</parameterid>                    
  74.                     <name>softness</name>                    
  75.                     <value>36</value>                
  76.                 </parameter>                
  77.                 <parameter>                    
  78.                     <parameterid>opacity</parameterid>                    
  79.                     <name>opacity</name>                    
  80.                     <value>100</value>                
  81.                 </parameter>            
  82.             </effect>        
  83.         </filter>    
  84.     </xsl:variable>    
  85.     <xsl:strip-space elements="*"/>    
  86.     <xsl:template match="node()//*">        
  87.         <xsl:if test="normalize-space(.)">            
  88.             <xsl:copy>                
  89.                 <xsl:apply-templates select="@*|node()"/>            
  90.             </xsl:copy>        
  91.         </xsl:if>    
  92.     </xsl:template>                
  93.     <xsl:template match="generatoritem[@id='Text']/effect">        
  94.         <xsl:copy>            
  95.             <xsl:copy-of select="*"/>            
  96.             <xsl:copy-of select="$textinfo"/>        
  97.         </xsl:copy>    
  98.     </xsl:template>    
  99.     <xsl:template match="generatoritem[@id='Text']">        
  100.         <xsl:copy-of select="*"/>
  101.         <xsl:copy-of select="$dropshadow"/>
  102.     </xsl:template>
  103.     <xsl:template match="@*|node()">        
  104.         <xsl:copy>
  105.             <xsl:apply-templates select="@*|node()"/>
  106.         </xsl:copy>
  107.     </xsl:template>
  108. </xsl:stylesheet>
  109.  
Apr 4 '07 #10
dorinbogdan
839 Expert 512MB
I simplified th XSL to text only "generatoritem[@id='Text']/effect":
[html]<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="UTF-8" standalone="yes" indent="yes"/>

<xsl:strip-space elements="*"/>
<xsl:template match="generatoritem[@id='Text']/effect">
<xsl:copy>
<xsl:copy-of select="*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>[/html]
and used this similar XML:
[html]<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="xmeml.xsl"?>
<xmeml>
<sequence>
<media>
<video>
<track>
<generatoritem id = "Text">
<name>Text1</name>
<effect>
<name>Text2</name>
<parameter>
<parameterid>Text3</parameterid>
</parameter>
</effect>
</generatoritem>
</track>
</video>
</media>
</sequence>
</xmeml>[/html]

When open the XML in IE and Firefox, it looks fine.
Apr 5 '07 #11
jtric
7
Thanks for your response. I must not have been exactly clear, sorry. As I noted earlier, I need to insert two sets of XML tags into two places in the existing XML. The XML tags are held in variables. I think I sort of got it working by changing from xsl: copy-of to xsl: apply-templates in one place... However I have no idea why that works.

I need the transform to insert the two variables ($textinfo and $dropshadow) into <generatoritem id="Text"> and the existing <generatoritem id="Text><effect>, as well as trip out all of the empty tags.

This (by changing the xsl: copy-of to xsl: apply-templates) works *except* that it strips id="text" from generatoritem.

If I change:
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="//generatoritem[@id='Text']">        
  2.         <xsl:copy>            
  3.             <xsl:apply-templates select="*"/>            
  4.             <xsl:copy-of select="$dropshadow"/>
  5.         </xsl:copy>    
  6.     </xsl:template>    
  7.  
to

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="//generatoritem[@id='Text']">        
  2.         <xsl:copy>            
  3.             <xsl:apply-templates select="@*"/>            
  4.             <xsl:copy-of select="$dropshadow"/>
  5.         </xsl:copy>    
  6.     </xsl:template>    
  7.  
It will keep the id="Text", but will not copy the $textinfo variable for some reason?

Appreciate any hints!

Here is the actual full XML and XSL I am working with:

XML
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  2. <xmeml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1">
  3.     <sequence>
  4.         <name>W01144</name>
  5.         <duration>601</duration>
  6.         <rate>
  7.             <ntsc>TRUE</ntsc>
  8.             <timebase>30</timebase>
  9.         </rate>
  10.         <media>
  11.             <video>
  12.                 <track>
  13.                     <clipitem id="5155-20-EINW">
  14.                         <name>5155-20-EINW</name>
  15.                         <duration>601</duration>
  16.                         <in>0</in>
  17.                         <out>601</out>
  18.                         <start>0</start>
  19.                         <end>901</end>
  20.                         <anamorphic>FALSE</anamorphic>
  21.                         <alphatype>none</alphatype>
  22.                         <file id="EINW">
  23.                             <name>EINW</name>
  24.                             <pathurl>file://localhost/Volumes/MediaDrive/Jesse/promos/promo_media/video/5155-20-EINW</pathurl>
  25.                             <duration>601</duration>
  26.                         </file>
  27.                         <filter>
  28.                             <effect>
  29.                                 <name>Basic Motion</name>
  30.                                 <effectid>basic</effectid>
  31.                                 <effectcategory>motion</effectcategory>
  32.                                 <effecttype>motion</effecttype>
  33.                                 <mediatype>video</mediatype>
  34.                                 <parameter>
  35.                                     <parameterid>center</parameterid>
  36.                                     <name>Center</name>
  37.                                     <value>
  38.                                         <horiz>0</horiz>
  39.                                         <vert>0</vert>
  40.                                     </value>
  41.                                 </parameter>
  42.                             </effect>
  43.                         </filter>
  44.                         <sourcetrack>
  45.                             <mediatype>video</mediatype>
  46.                         </sourcetrack>
  47.                     </clipitem>
  48.                     <generatoritem>
  49.                         <effect>
  50.                             <parameter/>
  51.                         </effect>
  52.                         <sourcetrack/>
  53.                     </generatoritem>
  54.                 </track>
  55.                 <track>
  56.                     <clipitem id="WCVWL3">
  57.                         <name>WCVWL3</name>
  58.                         <duration>300</duration>
  59.                         <in>0</in>
  60.                         <out>150</out>
  61.                         <start>751</start>
  62.                         <end>901</end>
  63.                         <anamorphic>FALSE</anamorphic>
  64.                         <alphatype>straight</alphatype>
  65.                         <file id="L3WCVW">
  66.                             <name>L3WCVW</name>
  67.                             <pathurl>file://localhost/Volumes/MediaDrive/Jesse/promos/promo_media/lower3rd/wcvwlower3rd.mov</pathurl>
  68.                             <duration>300</duration>
  69.                         </file>
  70.                         <filter>
  71.                             <effect>
  72.                                 <name>Basic Motion</name>
  73.                                 <effectid>basic</effectid>
  74.                                 <effectcategory>motion</effectcategory>
  75.                                 <effecttype>motion</effecttype>
  76.                                 <mediatype>video</mediatype>
  77.                                 <parameter>
  78.                                     <parameterid>center</parameterid>
  79.                                     <name>Center</name>
  80.                                     <value>
  81.                                         <horiz>0</horiz>
  82.                                         <vert>-0.00205761</vert>
  83.                                     </value>
  84.                                 </parameter>
  85.                             </effect>
  86.                         </filter>
  87.                         <sourcetrack>
  88.                             <mediatype>video</mediatype>
  89.                         </sourcetrack>
  90.                     </clipitem>
  91.                     <generatoritem>
  92.                         <effect>
  93.                             <parameter/>
  94.                         </effect>
  95.                         <sourcetrack/>
  96.                     </generatoritem>
  97.                 </track>
  98.                 <track>
  99.                     <clipitem>
  100.                         <file/>
  101.                         <filter>
  102.                             <effect>
  103.                                 <parameter>
  104.                                     <value/>
  105.                                 </parameter>
  106.                             </effect>
  107.                         </filter>
  108.                         <sourcetrack/>
  109.                     </clipitem>
  110.                     <generatoritem id="Text">
  111.                         <name>Text</name>
  112.                         <duration>3600</duration>
  113.                         <in>1650</in>
  114.                         <out>1776</out>
  115.                         <start>775</start>
  116.                         <end>901</end>
  117.                         <alphatype>black</alphatype>
  118.                         <effect>
  119.                             <name>Text</name>
  120.                             <effectid>Text</effectid>
  121.                             <effectcategory>Text</effectcategory>
  122.                             <effecttype>generator</effecttype>
  123.                             <mediatype>video</mediatype>
  124.                             <parameter>
  125.                                 <parameterid>str</parameterid>
  126.                                 <name>Text</name>
  127.                                 <value>Tonight at 8:00</value>
  128.                             </parameter>
  129.                         </effect>
  130.                         <sourcetrack>
  131.                             <mediatype>video</mediatype>
  132.                         </sourcetrack>
  133.                     </generatoritem>
  134.                 </track>
  135.             </video>
  136.             <audio>
  137.                 <track>
  138.                     <clipitem id="5155-20-EINW">
  139.                         <file id="EINW"/>
  140.                         <sourcetrack>
  141.                             <mediatype>audio</mediatype>
  142.                             <trackindex>1</trackindex>
  143.                         </sourcetrack>
  144.                     </clipitem>
  145.                 </track>
  146.                 <track>
  147.                     <clipitem id="5155-20-EINW">
  148.                         <file id="EINW"/>
  149.                         <sourcetrack>
  150.                             <mediatype>audio</mediatype>
  151.                             <trackindex>2</trackindex>
  152.                         </sourcetrack>
  153.                     </clipitem>
  154.                 </track>
  155.                 <track>
  156.                     <clipitem id="bobby-ton@8">
  157.                         <file id="bobbyton8">
  158.                             <name>bobby-ton@8</name>
  159.                             <pathurl>file://localhost/Volumes/MediaDrive/Jesse/promos/promo_media/voiceovers/bobby-ton@8</pathurl>
  160.                             <duration>125</duration>
  161.                         </file>
  162.                         <in>0</in>
  163.                         <out>125</out>
  164.                         <start>775</start>
  165.                         <end>900</end>
  166.                         <sourcetrack>
  167.                             <mediatype>audio</mediatype>
  168.                             <trackindex>1</trackindex>
  169.                         </sourcetrack>
  170.                     </clipitem>
  171.                 </track>
  172.                 <track>
  173.                     <clipitem id="bobby-ton@8">
  174.                         <file id="bobbyton8"/>
  175.                         <sourcetrack>
  176.                             <mediatype>audio</mediatype>
  177.                             <trackindex>2</trackindex>
  178.                         </sourcetrack>
  179.                     </clipitem>
  180.                 </track>
  181.             </audio>
  182.         </media>
  183.     </sequence>
  184. </xmeml>
  185.  

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    
  3.     <xsl:output method="xml" encoding="UTF-8" standalone="yes" indent="yes"/>    
  4.     <xsl:variable name="textinfo">            
  5.         <parameter>                
  6.             <parameterid>fontname</parameterid>                
  7.             <name>Font</name>                
  8.             <value>ITC Officina Sans</value>            
  9.         </parameter>            
  10.         <parameter>                
  11.             <parameterid>fontsize</parameterid>                
  12.             <name>Size</name>                
  13.             <value>39</value>            
  14.         </parameter>            
  15.         <parameter>                
  16.             <parameterid>fontstyle</parameterid>                
  17.             <name>Style</name>                
  18.             <value>1</value>            
  19.         </parameter>            
  20.         <parameter>                
  21.             <parameterid>fontalign</parameterid>                
  22.             <name>Alignment</name>                
  23.             <value>1</value>            
  24.         </parameter>            
  25.         <parameter>                
  26.             <parameterid>fontcolor</parameterid>                
  27.             <name>Font Color</name>                
  28.             <value>                    
  29.                 <alpha>255</alpha>                    
  30.                 <red>1</red>                    
  31.                 <green>2</green>                    
  32.                 <blue>3</blue>                
  33.             </value>            
  34.         </parameter>            
  35.         <parameter>                
  36.             <parameterid>origin</parameterid>                
  37.             <name>Origin</name>                
  38.             <value>                    
  39.                 <horiz>-0.101389</horiz>                    
  40.                 <vert>0.383604</vert>                
  41.             </value>            
  42.         </parameter>    
  43.     </xsl:variable>    
  44.     <xsl:variable name="dropshadow">        
  45.         <filter>            
  46.             <effect>                
  47.                 <name>Drop Shadow</name>                
  48.                 <effectid>dropshadow</effectid>                
  49.                 <effectcategory>motion</effectcategory>                
  50.                 <effecttype>motion</effecttype>                
  51.                 <mediatype>video</mediatype>                
  52.                 <parameter>                    
  53.                     <parameterid>offset</parameterid>                    
  54.                     <name>offset</name>                    
  55.                     <value>0</value>                
  56.                 </parameter>                
  57.                 <parameter>                    
  58.                     <parameterid>angle</parameterid>                    
  59.                     <name>angle</name>                    
  60.                     <value>135</value>                
  61.                 </parameter>                
  62.                 <parameter>                    
  63.                     <parameterid>color</parameterid>                    
  64.                     <name>color</name>                    
  65.                     <value>                        
  66.                         <alpha>0</alpha>                        
  67.                         <red>255</red>                        
  68.                         <green>255</green>                        
  69.                         <blue>255</blue>                    
  70.                     </value>                
  71.                 </parameter>                
  72.                 <parameter>                    
  73.                     <parameterid>softness</parameterid>                    
  74.                     <name>softness</name>                    
  75.                     <value>36</value>                
  76.                 </parameter>                
  77.                 <parameter>                    
  78.                     <parameterid>opacity</parameterid>                    
  79.                     <name>opacity</name>                    
  80.                     <value>100</value>                
  81.                 </parameter>            
  82.             </effect>        
  83.         </filter>    
  84.     </xsl:variable>    
  85.     <xsl:strip-space elements="*"/>    
  86.     <xsl:template match="node()//*">        
  87.         <xsl:if test="normalize-space(.)">            
  88.             <xsl:copy>                
  89.                 <xsl:apply-templates select="@*|node()"/>            
  90.             </xsl:copy>        
  91.         </xsl:if>    
  92.     </xsl:template>    
  93.     <xsl:template match="//generatoritem[@id='Text']">        
  94.         <xsl:copy>            
  95.             <xsl:apply-templates select="*"/>            
  96.             <xsl:copy-of select="$dropshadow"/>
  97.         </xsl:copy>    
  98.     </xsl:template>    
  99.     <xsl:template match="//generatoritem[@id='Text']/effect">        
  100.         <xsl:copy>            
  101.             <xsl:apply-templates select="*"/>            
  102.             <xsl:copy-of select="$textinfo"/>        
  103.         </xsl:copy>    
  104.     </xsl:template>    
  105.     <xsl:template match="@*|node()">        
  106.         <xsl:copy>            
  107.             <xsl:apply-templates select="@*|node()"/>        
  108.         </xsl:copy>    
  109.     </xsl:template>
  110. </xsl:stylesheet>
  111.  
Apr 5 '07 #12
dorinbogdan
839 Expert 512MB
Hmmm, big stuff....

I cannot get enough time today to research deeper.
Eventually, in the XSL, for the 2 variables try to use "value-of" instead of "copy-of" inside of <xsl:copy>.

For more details, see also xsl:copy and xsl:copy-of function reference.

God bless you,
Dorin.
Apr 5 '07 #13
jtric
7
Hmmm, big stuff....

I cannot get enough time today to research deeper.
Eventually, in the XSL, for the 2 variables try to use "value-of" instead of "copy-of" inside of <xsl:copy>.

For more details, see also xsl:copy and xsl:copy-of function reference.

God bless you,
Dorin.
It has grown a bit more complex than I'd anticipated, mostly because the original XML is exported from Excel and it does not like repeating nested elements. I really appreciate all your help. I will read up on xsl: copy-of and see if I can put it into use.
Apr 5 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Willing 2 Learn | last post by:
I'm working on this program below but im stuck. after it finds a match b/ween sentence & non_terminal it will output where these are found in both strings. I need it to spit out the rules with a...
32
by: FireHead | last post by:
Hello C World & Fanatics I am trying replace fgets and provide a equavivalant function of BufferedInputReader::readLine. I am calling this readLine function as get_Stream. In the line 4 where...
3
by: Simon Brooke | last post by:
As various people will have noticed, I've been having a lot of trouble with XSL lately. Brief history: I wrote myself an XML toolkit back in 2000, and it worked well enough for me, so it's been...
6
by: saif.shakeel | last post by:
Hi, I need to replace a string in xml file with something else.Ex - <SERVICEPARAMETER id="_775" Semantics="subfunction" DDORef="_54"> <SHORTNAME>rate</SHORTNAME> <LONGNAME>rate</LONGNAME>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.