Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Urgent! need help with dynamic DOCTYPE generation using XSLT [Thread Next] Re: Urgent! need help with dynamic DOCTYPE generation using XSLTTo: NULL Date: 3/1/2007 10:46:00 AM "Iwan" <Iwan@d...> wrote in message news:3BFF1455-80BE-4685-A8A3-B26A84D747C0@m...... > Hi everyone, > > I need help on how to dynamically generate a DOCTYPE declaration in an XML > file using XSLT. > Basically, I need to generate either one of the following DOCTYPE > declaration on my output XML file: > > <!DOCTYPE EE_Data SYSTEM "EEList_HLTP.dtd"> > > OR > > <!DOCTYPE EE_Data SYSTEM "EEListRep_HLTP.dtd"> > > > I have used <xsl:output> in my XSLT file, which looks like the following: > > <xsl:variable name="doctypeSystem"> > <xsl:choose> > <xsl:when > test="string-length(CBAEnvelope/CBABatchHeader/CBAApplication/Identifier[@Ty pe='Transact']/@UniqueID) = 0"> > <xsl:value-of select="'EEList_HLTP.dtd'"/> > </xsl:when> > <xsl:otherwise> > <xsl:value-of select="'EEListRep_HLTP.dtd'"/> > </xsl:otherwise> > </xsl:choose> > </xsl:variable> > > <xsl:output method="xml" indent="yes" doctype-system="$doctypeSystem"/> > > The idea here is that I have used a variable to store the value of the > doctype-system and assign to it later, but unfortunately this does not work. > > Anyone has any idea on how to make this work? I really need help on this > urgently. > > Thank you and kind regards, I can't think of a way to do this inside XSL. One option would be to create two other XSL files each import your original file. Then move the output element to these where one specifies the EEList dtd and the other EEListRep. You would then need external code to choose which of these to invoke:- sXPath = "CBAEnvelope/CBABatchHeader/CBAApplication/Identifier[@Type='Transact' and string-length(@UniqueID) = 0]" If Not oDOM.selectSingleNode(sXPath) Is Nothing Then 'Use EEList Else 'Use EEListRep End If | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
