Hi Chris

I've been unable to find any XSL processing instruction which forces a
transformation to use <foo /> rather than <foo></foo>. Using a DTD you can
ensure that your XML source document only validates when certain elements
are empty:

*** Your XML document ***
<?xml encoding='UTF-8'?>
<!ELEMENT data EMPTY>
<root>
<VG_Submission>
etc. 

But I don't think that this will help your situation. In any case, I'm sure
that the reason that there is no obvious way to determine the way that XSL
transformations deal with empty elements is because

<data></data> and <data />

are syntactically identical. If the third party receiving your documents has
a problem with the unabbreviated format then they can't be using a standard
XML processor - perhaps they have written their own program which uses
string parsing to get at the data. In this situation you could manipulate
your transformed document with ColdFusion string functions before passing it
on to them:

<cfset myxml = replacenocase(myxml,'></data>',' />','all')>

If you find an alternative do let us know about it!

Tom

-----------------+
tom dyson
t: +44 (0)1608 811870
m: +44 (0)7958 752657
http://torchbox.com

> I am using the XML toolkit for the transform.  I need to send the data to a
> third party, who has a set format that
> cannot be changed.  I do not know what parser they are using (I will ask).
> 
> The XML source is as follows:  (created by SQL Server 7 using SQLXML Web
> Release 2).
> 
> <root>
> <VG_Submission>
> <MemberID>95929</MemberID>
> <SubmissionID>4279</SubmissionID>
> [tags removed]
> <VG_FieldValue>
> <body>[long text removed]</body>
> <VG_SubmissionPackage><PackageID>96</PackageID></VG_SubmissionPackage>
> </VG_FieldValue>
> <VG_FieldValue>
> <body>[long text removed]</body>
> <VG_SubmissionPackage><PackageID>105</PackageID></VG_SubmissionPackage>
> </VG_FieldValue>
> </VG_Submission>
> </root>
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of tom dyson
> Sent: Friday, December 07, 2001 1:52 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [cf-xml] Unexpected output for XSLT
> 
> 
> Hi Chris
> 
> It would be good to see your XML source and the way that you're calling the
> transformation. Do you have any particular need to create the document in
> this format? All XML parsers that I know of (and definitely MSXML) will
> treat
> 
> <foo></foo>
> 
> just the same as
> 
> <foo />
> 
> So it shouldn't make any difference to your application, unless compactness
> is a key concern.
> 
> Tom
> 
> -----------------+
> tom dyson
> t: +44 (0)1608 811870
> m: +44 (0)7958 752657
> http://torchbox.com
> 
>> I have included a partial XSL sample that I am currently working with at the
>> bottom of this message.  I would like to
>> produce the following output:  (BTW, I am using MSXML4)
>> 
>> <data name="SubmissionID" value="1234" />
>> <data name="ProductSKU" value="x1234x5678" />
>> 
>> The output I am getting is this:
>> 
>> <data name="SubmissionID" value="1234" />
>> <data name="ProductSKU" value="x1234x5678"></data>
>> 
>> 
>> <xsl:element name="data">
>> <xsl:attribute name="name">SubmissionID</xsl:attribute>
>> <xsl:attribute name="value"><xsl:value-of select="//SubmissionID"
>> /></xsl:attribute>
>> </xsl:element>
>> <xsl:element name="data">
>> <xsl:attribute name="name">ProductSKU</xsl:attribute>
>> <xsl:attribute name="value"><xsl:for-each
>> select="//PackageID"><xsl:text>x</xsl:text><xsl:value-of select="."
>> /></xsl:for-each></xsl:attribute>
>> </xsl:element>


-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml

Reply via email to