View Single Post
 
Old 06-08-2017, 12:39 AM
slaycock slaycock is offline Windows 7 64bit Office 2013
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

Thanks for taking the time to look at the code and provide an example.

Unfortunately there are possibly still anomalies.

If I step through the code you kindly provided whilst watching what happens to the list of customXMLParts as seen from the XMLMappingPane (In the Developer Mapping Tab) you can see that the user defined namespaces are deleted. BUT

RCDP xmlns:a=""https://www.w3schools.com/furniture"" produces a namespace of (no namespace)

and

RCDP xmlns=""https://www.w3schools.com/furniture"" produces a namespace of https://www.w3schools.com/furniture


In the MsgBox statements

MsgBox ActiveDocument.CustomXMLParts(4).NamespaceURI
MsgBox ActiveDocument.CustomXMLParts(5).NamespaceURI

produce output of

Nothing
https://www.w3schools.com/furniture

whereas the last two msgbox statements produce

https://www.w3schools.com/furniture
https://www.w3schools.com/furniture

If I change the URI to furniture1 and furniture2 the same pattern persists.

In the XMP Mapping Pane

Furniture1 gives a namespace of (no namespace)
Furniture2 give a namespace of /www.w3schools.com/furniture2

The four Msgbox statements give output of

Nothing
https://www.w3schools.com/furniture2
https://www.w3schools.com/furniture1
https://www.w3schools.com/furniture2

This actually leaves me quite happy. The environment in which my code will be used its extremely unlikely there will be someone else using the same namespace and consequently I don't think I need to define a prefix (although that would be the more robust case).

But it would be useful to understand why we get (no namespace) when defining a prefix.

Also, I still can't find a way of making CustomXMLPrefixMappings.AddNamespace compile let alone test how it works.
Reply With Quote