EDN Admin
Well-known member
I want to add some new nodes to some XML output via XSLT. I have made some progress by using these forums but I have come across a problem.
I am trying to get this XML:
<dataroot>
<span style="white-spacere <JOB>
<span style="white-spacere <JOBDETAILS xmlnsd="urn:schemas-microsoft-comfficedata
<span style="white-spacere <JOBID>12699</JOBID>
<span style="white-spacere </JOBDETAILS>
<span style="white-spacere <ADDRESS xmlnsd="urn:schemas-microsoft-comfficedata
<span style="white-spacere <TYPE>Insured</TYPE>
<span style="white-spacere </ADDRESS>
<span style="white-spacere </JOB>
<dataroot>
To look like this:
<dataroot>
<span style="white-spacere <JOB>
<span style="white-spacere <JOBDETAILS xmlnsd="urn:schemas-microsoft-comfficedata
<span style="white-spacere <JOBID>12699</JOBID>
<span style="white-spacere </JOBDETAILS>
<span style="white-spacere <JOBADDRESSES>
<span style="white-spacere <span style="white-spacere
<ADDRESS xmlnsd="urn:schemas-microsoft-comfficedata
<TYPE>Insured</TYPE>
</ADDRESS>
</JOBADDRESSES>
</JOB>
<dataroot>
I am trying to add <JOBADDRESSES> above the <ADDRESS> node.
My transform file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xslutput method="xml" indent="yes"/>
<xsl:template match="dataroot
<dataroot>
<JOB>
<xsl:copy-of select="*"/>
</JOB>
</dataroot>
</xsl:template>
<xsl:template match="ADDRESS
<JOBADDRESSES>
<ADDRESS>
<xsl:copy-of select="*"/>
</ADDRESS>
</JOBADDRESSES>
</xsl:template>
</xsl:stylesheet>
As you can see I am already adding the <JOB> node which works fine. But if I try to add the <JOBADDRESSES> node nothing happens. I have tried to use the location code example here: http://social.msdn.microsoft.com/Forums/en/xmlandnetfx/thread/8722b40c-ff7d-4f51-bc70-aacdbced592c http://social.msdn.microsoft.com/Forums/en/xmlandnetfx/thread/8722b40c-ff7d-4f51-bc70-aacdbced592c which
has been helpful but for some reason I cannot get the second node transform to work. What I want to happen is very similar - as far as I can see - identical to this example but it doesnt work for me. I have tried changing the transform so that the first node
<JOB> is changed by using <span style="font-family:Consolas; font-size:13px; line-height:16px <span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial <<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:#2b91af; padding:0px; margin:0px; border:0px initial initial xsl:apply-templates <span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:red; padding:0px; margin:0px; border:0px initial initial select<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial ="<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial *"<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial /> instead
of <span style="font-family:Consolas; font-size:13px; line-height:16px <span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial <<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:#2b91af; padding:0px; margin:0px; border:0px initial initial xsl:copy-of <span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:red; padding:0px; margin:0px; border:0px initial initial select<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial ="<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial *"<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial /> but
that messes the whole output up and breaks the <JOBDETAILS> node altogether. What is it I am doing wrong?
<br/>
<br/>
View the full article
I am trying to get this XML:
<dataroot>
<span style="white-spacere <JOB>
<span style="white-spacere <JOBDETAILS xmlnsd="urn:schemas-microsoft-comfficedata
<span style="white-spacere <JOBID>12699</JOBID>
<span style="white-spacere </JOBDETAILS>
<span style="white-spacere <ADDRESS xmlnsd="urn:schemas-microsoft-comfficedata
<span style="white-spacere <TYPE>Insured</TYPE>
<span style="white-spacere </ADDRESS>
<span style="white-spacere </JOB>
<dataroot>
To look like this:
<dataroot>
<span style="white-spacere <JOB>
<span style="white-spacere <JOBDETAILS xmlnsd="urn:schemas-microsoft-comfficedata
<span style="white-spacere <JOBID>12699</JOBID>
<span style="white-spacere </JOBDETAILS>
<span style="white-spacere <JOBADDRESSES>
<span style="white-spacere <span style="white-spacere
<ADDRESS xmlnsd="urn:schemas-microsoft-comfficedata
<TYPE>Insured</TYPE>
</ADDRESS>
</JOBADDRESSES>
</JOB>
<dataroot>
I am trying to add <JOBADDRESSES> above the <ADDRESS> node.
My transform file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xslutput method="xml" indent="yes"/>
<xsl:template match="dataroot
<dataroot>
<JOB>
<xsl:copy-of select="*"/>
</JOB>
</dataroot>
</xsl:template>
<xsl:template match="ADDRESS
<JOBADDRESSES>
<ADDRESS>
<xsl:copy-of select="*"/>
</ADDRESS>
</JOBADDRESSES>
</xsl:template>
</xsl:stylesheet>
As you can see I am already adding the <JOB> node which works fine. But if I try to add the <JOBADDRESSES> node nothing happens. I have tried to use the location code example here: http://social.msdn.microsoft.com/Forums/en/xmlandnetfx/thread/8722b40c-ff7d-4f51-bc70-aacdbced592c http://social.msdn.microsoft.com/Forums/en/xmlandnetfx/thread/8722b40c-ff7d-4f51-bc70-aacdbced592c which
has been helpful but for some reason I cannot get the second node transform to work. What I want to happen is very similar - as far as I can see - identical to this example but it doesnt work for me. I have tried changing the transform so that the first node
<JOB> is changed by using <span style="font-family:Consolas; font-size:13px; line-height:16px <span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial <<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:#2b91af; padding:0px; margin:0px; border:0px initial initial xsl:apply-templates <span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:red; padding:0px; margin:0px; border:0px initial initial select<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial ="<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial *"<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial /> instead
of <span style="font-family:Consolas; font-size:13px; line-height:16px <span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial <<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:#2b91af; padding:0px; margin:0px; border:0px initial initial xsl:copy-of <span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:red; padding:0px; margin:0px; border:0px initial initial select<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial ="<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial *"<span style="font-weight:inherit; font-style:inherit; font-family:inherit; outline-width:0px; outline-style:initial; outline-color:initial; color:blue; padding:0px; margin:0px; border:0px initial initial /> but
that messes the whole output up and breaks the <JOBDETAILS> node altogether. What is it I am doing wrong?
<br/>
<br/>
View the full article