Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


How do I prevent the tranform from moving namespaces?

From: "Greg Collins" <gcollins_at_msn_dot_com>
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 



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent