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

[no subject]

Subject:
From: Dave Pawson <daveP@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 25 Aug 2000 21:13:28 +0100
[no subject]
Yet another use of XSLT? 


This from xml-dev.
I thought it might trigger some 
interest on xsl-list.
Regards DaveP




 >Justin Lipton asked about generating a simple, repetitive DTD structure 
 >automagically (see his post at the end). 
 > 
 >Simple - stick with xml and use an xslt stylesheet!. It's about as easy as 
 >programming it, possibly easier. Of course, you do have to create the xml 
 >file... 
 > 
 >Here's the input xml file: 
 > 
 ><things> 
 > <thing>Mammal</thing> 
 > <thing>Fish</thing> 
 > <thing>Bird</thing> 
 ></things> 
 > 
 >Here's the stylesheet (the mailer will break the lines at awkward places so 
 >I am also attaching it): 
 > 
 ><?xml version="1.0"?> 
 > 
 ><xsl:stylesheet version="1.0" 
 >xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
 ><xsl:output method='text' disable-output-escaping='yes'/> 
 > <xsl:template match="/things"><xsl:apply-templates/></xsl:template> 
 > 
 > <xsl:template match='thing'> 
 ><xsl:variable name='name' select='text()'/> 
 >&lt;!ELEMENT <xsl:value-of select='$name'/> (<xsl:value-of 
 >select='$name'/>Name, <xsl:value-of select='$name'/>Type)&gt; 
 >&lt;!ATTLIST <xsl:value-of select='$name'/>Name (latin|common) "common"&gt; 
 >&lt;!ELEMENT <xsl:value-of select='$name'/>Type (#PCDATA)&gt; 
 > </xsl:template> 
 > 
 ></xsl:stylesheet> 
 > 
 >Here's the output, just what you asked for: 
 > 
 >D:>xt things.xml things.xsl 
 > 
 > 
 ><!ELEMENT Mammal (MammalName, MammalType)> 
 ><!ATTLIST MammalName (latin|common) "common"> 
 ><!ELEMENT MammalType (#PCDATA)> 
 > 
 > 
 ><!ELEMENT Fish (FishName, FishType)> 
 ><!ATTLIST FishName (latin|common) "common"> 
 ><!ELEMENT FishType (#PCDATA)> 
 > 
 > 
 ><!ELEMENT Bird (BirdName, BirdType)> 
 ><!ATTLIST BirdName (latin|common) "common"> 
 ><!ELEMENT BirdType (#PCDATA)> 
 > 
 >Cheers, 
 > 
 >Tom Passin


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


Current Thread
  • [no subject]
    • Dave Pawson - Fri, 25 Aug 2000 21:13:28 +0100 <=

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.