xsl-list
[Top] [All Lists]

RE: [xsl] apply one template to another

2006-11-01 08:14:21

WOW, thank you very much. Im amazed at the elegance of your solution -
ive taken time to understand how the XPath expressions work in your
solution and it really is very neat.

Thanks very much again :-)

Adam.


-----Original Message-----
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk] 
Sent: 01 November 2006 15:03
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] apply one template to another



My input document that could be processed is at the bottom of my
originial post,

so it is!, sorry...


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="2.0"
                >
  
  <xsl:strip-space elements="*"/>
  <xsl:output indent="yes"/>
  
  <xsl:template match="*" mode="copy">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates mode="copy"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="*[not(self::xform)][name()=/root/*/name()]"
mode="copy">
    <xsl:copy-of select="/root/*[name()=name(current())]"/>
  </xsl:template>
  
  
  <xsl:template match="/root">
    <xsl:apply-templates mode="copy" select="xform"/>
  </xsl:template>
  
  
  
</xsl:stylesheet>


$ saxon8 copy.xml copy.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xform xmlns:xlink="http://www.w3.org/1999/xlink";
       xmlns:xs="http://www.w3.org/2001/XMLSchema";
       xmlns:ev="http://www.w3.org/2001/xml-events";
       xmlns:xforms="http://www.w3.org/2002/xforms";>
   <xforms:model ev:event="xforms-revalidate" ev:defaultAction="cancel">
      <xforms:submission id="submit"
 
action="http://localhost:8080/exist/servlet/db/CommunityDirectory/index.
xql?action=savepage"
                         method="post"
                         replace="all"/>
      <xforms:instance>
         <page design="event">
            <title/>
            <description/>
            <when>
               <start>2006-11-01T09:00:00.00</start>
               <end>2006-11-01T18:00:00.00</end>
               <occurs>Once</occurs>
            </when>
            <contact>
               <title>Miss</title>
               <firstname>Jo</firstname>
               <lastname>Smith</lastname>
               <telephone>
                  <number type="Office">01404 812345</number>
               </telephone>
            </contact>
            <location>
               <address>The Old Institute</address>
               <address>Yonder Street</address>
               <town>Ottery St Mary</town>
               <county>Devon</county>
               <postcode>EX11 1XX</postcode>
            </location>
            <cost/>
         </page>
      </xforms:instance>
   </xforms:model>
</xform>


--~------------------------------------------------------------------
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>
--~--