Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: How do I prevent the tranform from moving namespaces? How do I prevent the tranform from moving namespaces?To: NULL Date: 5/20/2008 5:55:00 AM PROBLEM: I am trying to get perform a transform of an XML document into a WordML document. There's one hangup I'm having, preventing the creation of a valid WordML doc. WordML is apparently VERY picky about what element the namespace declaration appears on, and XSLT is rather manipulative about where it places them--disregarding where I have them in the transform. So for example, I have: <xsl:template name="foo"> <pkg:part pkg:name="/docProps/custom.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.custom-properties+xml" pkg:padding="256"> <pkg:xmlData> <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"> <property fmtid="{{D5CDD505-2E9C-101B-9397-08002B2CF9AE}}" pid="2" name="Customer"> <vt:lpwstr> <xsl:value-of select="/my:myFields/my:Project"/> </vt:lpwstr> </property> </Properties> </pkg:xmlData> </pkg:part> </xsl:template> But what I get out of it is: <pkg:part pkg:name="/docProps/custom.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.custom-properties+xml" pkg:padding="256"> <pkg:xmlData> <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"> <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="Customer" xmlns=""> <vt:lpwstr xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">Exchange 2007 Migration</vt:lpwstr> </property> </Properties> </pkg:xmlData> </pkg:part> Note that xmlns:vt has been moved duing the transform from the Properties element to the vt:lpwstr element. While in theory, this should not be an issue (and isn't through the rest of the document with other namespaces where this occured), this particular namespace is causing the resulting WordML to become invalid. Word is expecting and demanding that it be placed onthe Properties element in order for the document to be valid. I've done a diff of all other changes, and they all work fine except for the case of this one namespace. Why it makes a difference I don't know, but it does. QUESTION: So somehow I need to force that namespace to appear on the Properties element instead of being moved down to the elements that uses the namespaces. How do I do this without having to do something completely obnoxious like convert 6000 lines into tons more by using <xsl:element/> and <xsl:attribute/> everywhere? -- Greg Collins Microsoft MVP Visit Braintrove at http://www.braintrove.com Visit InfoPathDev at http://www.infopathdev.com | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
