Jump to content

copy-of


Jano

Recommended Posts

xsl:copy-of problemunwanted attribute

Im trying to make a xsl transformation from another xsl. Original file transform.xsl is just showing whats in xml. New file create-tranform-edit.xsl should create a xsl that will show xml data in edit boxes, so it would be editable. Im "compiling" it using one java class transform.class.This is how transform.xsl looks like:

[size=1]<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    <xsl:output method="html"/>        <xsl:template match="/">        <html>            <head>                <title><xsl:value-of select="module/title"/></title>                <meta http-equiv="Content-Language" content="sk" />                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />            </head>            <body>                <b>                <xsl:apply-templates/>                </b>            </body>        </html>    </xsl:template>...[/size]

This is how create-transform-edit.xsl looks:

[size=1]<?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"/>     <xsl:template match="/">        <xsl:text disable-output-escaping="yes"><![CDATA[    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    <xsl:output method="html"/>]]></xsl:text>      <xsl:text disable-output-escaping="yes"><![CDATA[<xsl:template match="/"><html>]]></xsl:text>        <xsl:copy-of select="//xsl:template/html/head/." />  <xsl:template match="xsl:template/body">         	<body>           <form action="url" method="get">           <div widht="100%">            	<input type="submit" value="Submit" />            	</div>            	<xsl:copy-of select="//xsl:template/html/body/child::node()" />            	</form>	       	</body>	       	<xsl:text disable-output-escaping="yes"><![CDATA[</html>]]></xsl:text>           <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:template>]]></xsl:text>           <xsl:apply-templates/>           <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:stylesheet>]]></xsl:text>           </xsl:template>    </xsl:template>... [/size] 

This is the result i get transform-edit.xsl:

[size=1]<?xml version="1.0" encoding="UTF-8"?>    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    <xsl:output method="html"/><xsl:template match="/">        <html>[/size]       [size=3][b] <head xmlns:xsl="http://www.w3.org/1999/XSL/Transform">[/b][/size]                [size=1]<title><xsl:value-of select="module/title"/></title>                <meta http-equiv="Content-Language" content="sk"/>                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>            </head><body><form action="url" method="get"><div widht="100%"><input type="submit" value="Submit"/></div>[/size]                [b][size=3]<b xmlns:xsl="http://www.w3.org/1999/XSL/Transform">[/size][/b]                [size=1]<xsl:apply-templates/>                </b>            </form></body></html></xsl:template>[/size]

I cant findout why i do get as an attribute xmlns:xsl="http://www.w3.org/1999/XSL/Transform" in <head> and in <b>Please, could you help me?Btw I would like to thank kaijim or someone responsible for validating me for posting so soon.

Link to comment
Share on other sites

I'm wondering if you are not getting hit by the built-in (in XSLT) template that matches whatever text is not matched by any of your templates. Have you tried creating a template that matches the namespace string you are getting and then just do nothing about it?CzechM8

Link to comment
Share on other sites

More info:"When the XSLT processor can't find a template to match the node that it's been told to process, it uses a built-in template. If you find that the result of your stylesheet includes text you didn't expect, the chances are that it's due to the built-in templates. Just because there isn't a template for a particular node that doesn't mean that it's not processed."This can be found at: http://www.codetoad.com/xml/xslt5.aspHope this helps.CzechM8

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...