This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: seamless processing of multiple XML fragments


You can just add a template to your stylesheet that processes your
include elements. Here, for example, is a stylesheet that does an
identity transform with any depth of includes in your sample files.
Replace the identity transform with your own templates and you need not
be concerned about the include elements. 

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

  <xsl:output method="xml" indent="yes" />
  <xsl:strip-space elements="*"/>

  <xsl:template match="include">
    <xsl:apply-templates select="document(@file)/*"/>
  </xsl:template>

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


Dan

-----Original Message-----
From: Dan Diebolt [mailto:dandiebolt@yahoo.com]
Sent: Monday, September 03, 2001 2:28 PM
To: xsl-list@lists.mulberrytech.com
Subject: [xsl] seamless processing of multiple XML fragments


I have some xml that looks like this conceptually:

 <root>
  <a>
   <b>B</b>
   <c>
    <d>D</d>
    <e>E</e>
    <f>F</f>
   </c>
  </a>
  <g>
   <h>H</h>
   <i>I</i>
  </g>
 </root>

However, the XML is actually stored in two files:

 File1.xml:
 <root>
  <a>
   <b>B</b>
   <include file="File2.xml"/>
  </a>
  <g>
   <h>H</h>
   <i>I</i>
  </g>
 </root>

 File2.xml:
 <c>
  <d>D</d>
  <e>E</e>
  <f>F</f>
 </c>

The tag <include file="File2.xml"/> conceptually shows where the xml 
fragment in the second file should be inserted into xml fragment in 
the first file. I could accept any mechanism that allows this type
of insertion. Here is my questions to the list: Is there a way to
implement this so that the XSLT processing is seamless? I don;t
want to concern myself with tracing nested includes in writing the
XSLT. Your help is appreciated.

Regards,

Dan


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo!
Messenger
http://im.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]