Wednesday

To change xml namespace definition you can try this xsl,see input



<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:NAME="old_namespace">

<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>

<xsl:template match="NAME:*">
<xsl:element name="{name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>

<xsl:template match="ROOT">
<xsl:element name="ROOT">
<xsl:attribute name="xmlns:NAME">http://tempuri.org/mynew</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>

</xsl:stylesheet>


If you put in input an XML like this:

<?xml version = '1.0' encoding = 'ISO-8859-1'?>
<ROOT xmlns:NAME='old_namespace'>
<NAME:element attr1="xxx" >
<NAME:subElement attr2="yyy">abcdefghi</NAME:subElement>
</NAME:element>
<NAME:element attr1="xxx" >
<NAME:subElement attr2="yyy">abcdefghi</NAME:subElement>
</NAME:element>
</ROOT>

The output message will be:


<?xml version="1.0" encoding="ISO-8859-1"?>
<ROOT xmlns:NAME="http://example.org/new">
<NAME:element attr1="xxx">
<NAME:subElement attr2="yyy">abcdefghi</NAME:subElement>
</NAME:element>
<NAME:element attr1="xxx">
<NAME:subElement attr2="yyy">abcdefghi</NAME:subElement>
</NAME:element>
</ROOT>



more...

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...