Is it possible to use XSLT to transform XML into something other than XML?
e.g. i want the final non-xml content:
<Content>
<image url="file1.png">
<image url="file2.png">
...
<image url="filen.png">
<EndContent>
You're notice this document is not xml (or even html), but it does have <elements>
.
Is it possible, using XSLT, to generate non-xml output?
Another example of non-xml output might be:
<HTML>
<BODY>
<IMG src="file1.png"><BR>
<IMG src="file2.png"><BR>
...
<IMG src="filen.png"><BR>
</BODY>
</HTML>
You'll notice this document is HTML, because in HTML IMG
and BR
tags are forbidden from having a closing tag. This constrasts with xhtml, the reformulation of HTML using xml, where all elements are required from having a closing tag (because in xml every tag must be closed).
Another example of non-xml output might be:
INSERT INTO Documents (Filename) VALUES ('file1.png')
INSERT INTO Documents (Filename) VALUES ('file2.png')
...
INSERT INTO Documents (Filename) VALUES ('file3.png')
i can make up any source xml i like, but one example might be:
Source xml:
<DocumentStore>
<Document type="image">file1.png</Document>
<Document type="image">file2.png</Document>
<Document type="image">filen.png</Document>
</DocumentStore>
Or perhaps:
<Profiles>
<User avatar="file1.png" />
<User avatar="file2.png" />
<User avatar="filen.png" />
</Profiles>
Yes, you can, by using the xsl:output element in your stylesheet.
No matter how you create your IMG tags,
The output method "html" will cause the IMG tags to not be closed.
You can use
<xsl:output>
to specify the output format, which doesn't have to be xml, see this reference page.However, if you are outputting html, no modern browser should complain even if you do put the closing tags, so using your example above, i believe all browser should be ok with :-
So not too sure why you don't want to put the closing tag, unless i'm missing something.
Update: Added example of non xml output
Given this stylesheet:-
and this input xml:-
You get output like this:-