xslt to add an attribute -
I have to add a namespace, and to add one attribute to some nodes. With this input:
& lt; Root & gt; & Lt; Node1 & gt; Trial & lt; / Node1 & gt; & Lt; Dated / & gt; & Lt; / Root & gt;
I want this output:
& lt; My: root xmlns: my = "http://schemas.microsoft.com/office/infopath/ 2003 / myXSD / 2010-07-28T07: 33: 11" & gt; & Lt; Mary: node1 & gt; Trial & lt; / Mary: node1 & gt; & Lt; My: DateTo xsi: nil = "true" /> & Lt; / My: root & gt;
The Detro Node requires this attribute set.
I successfully added the namespace with this transform, but the attribute can not be added.
& lt; Xsl: stylesheet xmlns: xsl = 'http: //www.w3.org/1999/XSL/Transform' version = '1.0' & gt; & Lt; Xsl: template match = '*' & gt; & Lt; Xsl: element name = 'my: {local name ()}' name space = 'http: //schemas.microsoft.com/office/infopath/2003/myXSD/2010-07-28T07: 33: 11' & gt; & Lt; Xsl: applied-template / & gt; & Lt; / XSL: element & gt; & Lt; / XSL: Templates & gt; & Lt; / Xsl: stylesheet & gt; "
I get this error " Attribute and Namespace nodes can not be added to the basic element after text, comment, PI or sub-element node has already been added is. " Be thankful for any help here.
You can try additional attributes To insert the following:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & lt; xsl: stylesheet xmlns: xsl = 'http: /www.w3.org/1999/XSL/Transform 'xmlns: xsi =' http: //www.w3.org/2001/XMLSchema-instance 'version =' 1.0 '& gt; & lt; xsl: template match = '*' & Gt; & lt; xsl: element name = 'my: {local-name ()}' xmlns: my = 'http: //schemas.microsoft.com/office/infopath/2003/myXSD/2010 -07-28T07: 33: 11 & lt; xsl: if test = "no (*) and no (normal-space ())" & gt; xsl: attribute nam E = "xsi: nil" & gt; & lt; xsl: value-select = "true ()" and
Comments
Post a Comment