Ik ben sinds een paar dagen wat aan het klooien met XSLT en probeer nu de volgende xml file:
te transformeren met de volgende XSL:
Het probleem is dat de body node niet goed gekopieerd wordt. De output is:
Als ik nu echter in de source file de xmlns attribute van de body tag weghaal wordt de body tag wel gekopieerd:
Echter heb ik aan deze output helemaal niks, aangezien hij met de xmlns="" attribuut de body natuurlijk niet goed rendert.
Heeft iemand suggesties
?
XML:
1
2
3
4
5
6
7
8
| <?xml version="1.0" encoding="UTF-8"?> <structure> <title>Overview</title> <body xmlns="http://www.w3.org/1999/xhtml" xmlns:com="http://uplinx.eu/framework/components"> <p>Welcome!</p> <com:test /> </body> </structure> |
te transformeren met de volgende XSL:
XML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" /> <xsl:template match="/structure"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><xsl:value-of select="title" /></title> </head> <xsl:copy-of select="body" /> </html> </xsl:template> </xsl:stylesheet> |
Het probleem is dat de body node niet goed gekopieerd wordt. De output is:
XHTML:
(zonder de betreffende body node dus).1
2
3
4
5
6
7
| <?xml version="1.0" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Overview</title> </head> </html> |
Als ik nu echter in de source file de xmlns attribute van de body tag weghaal wordt de body tag wel gekopieerd:
XHTML:
(NB: de com:test wordt verderop ook vervangen)1
2
3
4
5
6
7
8
9
10
11
| <?xml version="1.0" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Overview</title> </head> <body xmlns:com="http://uplinx.eu/framework/components" xmlns=""> <p>Welcome!</p> <div><hr/>Component: test<hr/></div> </body> </html> |
Echter heb ik aan deze output helemaal niks, aangezien hij met de xmlns="" attribuut de body natuurlijk niet goed rendert.
Heeft iemand suggesties