OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   xsl -- Inserting a DOCTYPE if needed

[ Lists Home | Date Index | Thread Index ]




How would write a XSL file that inserts the DOCTYPE only and only if not
present?

// Source 1 //-- HAS DOCTYPE
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE RootElement SYSTEM "../DTDs/RootElement.dtd">
<RootElement>
	...
	...
</RootElement>


// Source 2  //-- NO DOCTYPE
<?xml version="1.0" encoding="UTF-8"?>
<RootElement>
	...
	...
</RootElement>



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

<!-- This is what I need to make conditional -->
<!-- If the DOCTYPE is not found insert the DOCTYPE with this xsl output -->
<xsl:output method="xml" indent="yes" doctype-public="some_URI"
doctype-system ="path/dtdFile.dtd"/>
<!-- BUT I DON'T KNOW ENOUGH ABOUT XSL TO CHECK FOR DOCTYPE -->


<!-- This makes a copy of the RootElements-->
<xsl:template match="RootElement">
   <xsl:copy-of select="../*"/>
</xsl:template>

</xsl:stylesheet>

Thanks







 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS