Answer the question
In order to leave comments, you need to log in
Two-in-one: XML+XSLT?
So, I decided: to try to shove the XSLT template inside XML, (similar to including a CSS style sheet inside [X]HTML) so that I can then get a valid XTHML page at the output. Well, and to the heap, I also screwed up the doctype declaration.
So here's what the hell I've done here:
<?xml version="1.0" encoding="windows-1251"?>
<?xml-stylesheet type="text/xml" href="#xstyle"?>
<!DOCTYPE doc [
<!ELEMENT doc (xsl,component)>
<!ELEMENT component (software)>
<!ELEMENT software (#PCDATA)>
<!ELEMENT xsl (xsl:stylesheet)>
<!ELEMENT xsl:stylesheet (xsl:output, xsl:template*)>
<!ATTLIST xsl:stylesheet
version CDATA #REQUIRED
id ID #REQUIRED
xmlns:xsl CDATA #IMPLIED
xmlns:fo CDATA #IMPLIED
xmlns:xs CDATA #IMPLIED
xmlns:fn CDATA #IMPLIED
xmlns:xdt CDATA #IMPLIED
>
<!ELEMENT xsl:output EMPTY>
<!ATTLIST xsl:output
version CDATA #IMPLIED
indent CDATA #IMPLIED
standalone CDATA #IMPLIED
omit-xml-declaration CDATA #IMPLIED
doctype-public CDATA #IMPLIED
doctype-system CDATA #IMPLIED
method CDATA #REQUIRED
encoding CDATA #REQUIRED
media-type CDATA #IMPLIED
>
<!ELEMENT xsl:template (#PCDATA|html)*>
<!ATTLIST xsl:template match CDATA #IMPLIED>
<!ELEMENT xsl:apply-templates EMPTY>
<!ELEMENT html (head,body)>
<!ELEMENT head (title)>
<!ELEMENT body (h1)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT h1 (xsl:apply-templates)?>
]>
<doc>
<xsl>
<xsl:stylesheet id="xstyle"
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="Windows-1251"
omit-xml-declaration="yes"
standalone="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
indent="yes"
media-type="text-html" />
<xsl:template match="/doc/component/software">
<html><head><title>xxx</title></head><body>
<h1><xsl:apply-templates/></h1>
</body></html>
</xsl:template>
<xsl:template match="xsl:stylesheet"/>
</xsl:stylesheet>
</xsl>
<component>
<software>qqq</software>
</component>
</doc>
And now how to get this out of all this?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=Windows-1251" />
<title>xxx</title>
</head>
<body>
<h1>qqq</h1>
</body>
</html>
Maybe I made a wrong link to the internal XSL template? Answer the question
In order to leave comments, you need to log in
So what does the XSLT transformer write when trying to digest a file?
Beautiful! Ahahaha! It's funny for you, but for me, at work, everything works like that. It's funny to you, but it even made me sad :'(
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question