[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Extracting a comment block

Subject: Re: Extracting a comment block
From: George Cristian Bina <george@xxxxxxx>
Date: Sat, 18 Sep 2004 00:54:10 +0300
xml comment block
Hi Mila,

You can use comment() to match comment nodes in your XML document.
For instance the following stylesheet will copy the comments inside Alias_Records inside the comments element in the output. Each comment will be followed by the following sibling node if that is a text (in order to get the new lines following the comment nodes in the output as well):


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<comments>
<xsl:apply-templates select="Alias_Records/comment()"/>
</comments>
</xsl:template>
<xsl:template match="comment()">
<xsl:copy/>
<xsl:copy-of select="following-sibling::node()[1][self::text()]"/>
</xsl:template>
</xsl:stylesheet>


<?xml version="1.0" encoding="UTF-8"?>
<comments><!-- ********************************************************* -->
 <!-- Local SITE ID        : xxx                               -->
 <!-- Local Release Version: lny0211i                          -->
 <!-- NASD/NADR Version    : 31n0211r                          -->
 <!-- Date                 : 09-02-2004 12:10:39               -->
 <!-- *********************************************************- -->
     </comments>

Hope that helps,
George
-----------------------------------------------
George Cristian Bina
<oXygen/> XML Editor & XSLT Editor/Debugger
http://www.oxygenxml.com


Mila P. Mitra wrote:
Hello,
  First of all let me thank all the people who run this list and answer
questions frequently for a great job.

Here is my question. Is there a way to use a stylesheet to extract a comment
block as is and take it across to a new xml file?

The example below shows the 4 lines of comments within the ***** lines,
which I want also printed in the new XML file exactly the way it is:

<?xml version="1.0"?>
<Alias_Records xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="Alias.xsd">
 <!-- ********************************************************* -->
 <!-- Local SITE ID        : xxx                               -->
 <!-- Local Release Version: lny0211i                          -->
 <!-- NASD/NADR Version    : 31n0211r                          -->
 <!-- Date                 : 09-02-2004 12:10:39               -->
 <!-- *********************************************************- -->
     <FixAlias>
       <AliasAlphanumerics>SCB</AliasAlphanumerics>
       <FixName>KSCB</FixName>
     </FixAlias>
     <AirportAlias>
       <AliasAlphanumerics>YYZ</AliasAlphanumerics>
       <AirportID>VYZX</AirportID>
     </AirportAlias>
</Alias_Records>

Thanks in advance,
Mila Mitra

---------------------------------------------
Mila (Patralekha) Mitra
pmitra@xxxxxxxxxxxxxxxxx
NASA Ames, CA


--+------------------------------------------------------------------ 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@xxxxxxxxxxxxxxxxxxxxxx> --+--

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.