← Prev in month ← Prev in thread

xsl -- Inserting a DOCTYPE if needed

From
Caro, Samuel <>
To
"''" <>
Date
2002-03-12T07:31:33Z
ID
<>
Thread
xsl -- Inserting a DOCTYPE if needed
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
← Prev in month ← Prev in thread