Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Urgent! need help with dynamic DOCTYPE generation using XSLT

From: "Anthony Jones" <Ant@------------.--->
To: 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





transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent