XSL copy-of problem!
-
Hi All! The advice I got from this forum in regards to using copy-of instead of value-of was excellent, my XSL is working almost perfectly, however there is one small problem. This XSL:
<xsl:template match="/HTML/BODY//B">
<B ID="{@ID}" CLASS="{@CLASS}" TITLE="{@TITLE}" STYLE="{@STYLE}" DIR="{@DIR}" LANG="{@LANG}" ONFOCUS="{@ONFOCUS}" ONBLUR="{@ONBLUR}" ONCLICK="{@ONCLICK}" ONDBLCLICK="{@ONDBLCLICK}" ONMOUSEDOWN="{@ONMOUSEDOWN}" ONMOUSEUP="{@ONMOUSEUP}" ONMOUSEOVER="{@ONMOUSEOVER}" ONMOUSEMOVE="{@ONMOUSEMOVE}" ONMOUSEOUT="{@ONMOUSEOUT}" ONKEYPRESS="{@ONKEYPRESS}" ONKEYDOWN="{@ONKEYDOWN}" ONKEYUP="{@ONKEYUP}">
<xsl:copy-of select="."/>
</B>
</xsl:template>Produces this output:
<B ONCLICK="" ONDBLCLICK="" ONMOUSEDOWN="" ONMOUSEUP="" ONMOUSEOVER="" ONMOUSEMOVE="" ONMOUSEOUT="" ONKEYPRESS="" ONKEYDOWN="" ONKEYUP="" ID="" CLASS="" TITLE="" STYLE="" DIR="" LANG="">
<B>
Hello World!
</B></B>From this input:
<B>
Hello World!</B><BR/>
The B tags are being duplicated due to my use of the "." Xpath syntax, however when I tried "child::*" the text inside all single level tags like:
<B>Hello World!</B>
is not displayed at all. Can anybody suggest a soloution to this problem. Thanks! MrWolfy :-D
-
Hi All! The advice I got from this forum in regards to using copy-of instead of value-of was excellent, my XSL is working almost perfectly, however there is one small problem. This XSL:
<xsl:template match="/HTML/BODY//B">
<B ID="{@ID}" CLASS="{@CLASS}" TITLE="{@TITLE}" STYLE="{@STYLE}" DIR="{@DIR}" LANG="{@LANG}" ONFOCUS="{@ONFOCUS}" ONBLUR="{@ONBLUR}" ONCLICK="{@ONCLICK}" ONDBLCLICK="{@ONDBLCLICK}" ONMOUSEDOWN="{@ONMOUSEDOWN}" ONMOUSEUP="{@ONMOUSEUP}" ONMOUSEOVER="{@ONMOUSEOVER}" ONMOUSEMOVE="{@ONMOUSEMOVE}" ONMOUSEOUT="{@ONMOUSEOUT}" ONKEYPRESS="{@ONKEYPRESS}" ONKEYDOWN="{@ONKEYDOWN}" ONKEYUP="{@ONKEYUP}">
<xsl:copy-of select="."/>
</B>
</xsl:template>Produces this output:
<B ONCLICK="" ONDBLCLICK="" ONMOUSEDOWN="" ONMOUSEUP="" ONMOUSEOVER="" ONMOUSEMOVE="" ONMOUSEOUT="" ONKEYPRESS="" ONKEYDOWN="" ONKEYUP="" ID="" CLASS="" TITLE="" STYLE="" DIR="" LANG="">
<B>
Hello World!
</B></B>From this input:
<B>
Hello World!</B><BR/>
The B tags are being duplicated due to my use of the "." Xpath syntax, however when I tried "child::*" the text inside all single level tags like:
<B>Hello World!</B>
is not displayed at all. Can anybody suggest a soloution to this problem. Thanks! MrWolfy :-D
Starting to feel sort of responsible for your project... I'm not sure what the problem is this time though. What's the overall goal of your transformation? Do you want to a) copy all the B and EM tags of some HTML to a self defined XML( or HTML) structure, or b) reproduce a complete HTML with all B and EM tags having a set of attributes which may be missing in the original? When a: what's your target structure? When b: probably a little recursion is called for. http://www.xmlplease.com/xsltidentity might be a good link to start with.
-
Starting to feel sort of responsible for your project... I'm not sure what the problem is this time though. What's the overall goal of your transformation? Do you want to a) copy all the B and EM tags of some HTML to a self defined XML( or HTML) structure, or b) reproduce a complete HTML with all B and EM tags having a set of attributes which may be missing in the original? When a: what's your target structure? When b: probably a little recursion is called for. http://www.xmlplease.com/xsltidentity might be a good link to start with.
Hi and Thanks! Frank... Your help has been fantastic, clear and precise. If not for your help I'd still be trying to copy nodes with value-of :laugh: . The article you provided solved my problem completely and was exactly what I was looking for. However there is just one more little nagging detail. How would I only output attributes with a value, so that all attributes such as ONCLICK="" will not be displayed? Thanks for all your help! MrWolfy :-D
-
Hi and Thanks! Frank... Your help has been fantastic, clear and precise. If not for your help I'd still be trying to copy nodes with value-of :laugh: . The article you provided solved my problem completely and was exactly what I was looking for. However there is just one more little nagging detail. How would I only output attributes with a value, so that all attributes such as ONCLICK="" will not be displayed? Thanks for all your help! MrWolfy :-D
In the article they suppress the id attributes with the help of a template which matches them but does nothing. I think you're looking for something like Haven't tried it out though; could be faulty, but I hope you get the idea.
-
In the article they suppress the id attributes with the help of a template which matches them but does nothing. I think you're looking for something like Haven't tried it out though; could be faulty, but I hope you get the idea.
Hi and Thanks! Thanks Frank! Problem solved, that template was just what I needed to complete my project! Thanks Again! MrWolfy :-D