Hello,
I'm trying to round-trip some XML out of Adobe InDesign, through my
application and then back into InDesign.
Tables in InDesign are created using a specific namespace like this:
<Table TABLE_TYPE="table05"
xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:table="table"
aid:trows="7" aid:tcols="2">
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"
aid:ccolwidth="73.79470231328037"> etc.
Now, I'm looking to add a new table, so what I'm doing is constructing it
using the following code (VB.NET):
Dim customElement As XmlElement = ProductGuideExport.DestinationXMLDoc. _
CreateElement("table")
Dim newAttrib As XmlAttribute = CreateNewAttrib(customElement, _
"TABLE_TYPE", "table05")
newAttrib = CreateNewAttrib(customElement, "xmlns:aid",
"http://ns.adobe.com/AdobeInDesign/4.0/")
newAttrib = CreateNewAttrib(customElement, "table", "table", "aid")
newAttrib = CreateNewAttrib(customElement, "trows", "3", "aid")
newAttrib = CreateNewAttrib(customElement, "cols", "5", "aid")
etc...
where my CreateNewAttrib method is overloaded as:
Private Shared Function CreateNewAttrib(ByVal Element As Xml.XmlElement, _
ByVal Name As String, ByVal Value As String) As Xml.XmlAttribute
Dim newAttrib1 As XmlAttribute = _
Element.OwnerDocument.CreateAttribute(Name)
newAttrib1.Value = Value
Return Element.Attributes.Append(newAttrib1)
End Function
Private Shared Function CreateNewAttrib(ByVal Element As Xml.XmlElement, _
ByVal QulifiedName As String, ByVal Value As String, _
ByVal URI As String) As Xml.XmlAttribute
Dim newAttrib1 As XmlAttribute = Element.OwnerDocument.CreateAttribute _
(QulifiedName, URI)
newAttrib1.Value = Value
Return Element.Attributes.Append(newAttrib1)
End Function
This results in the following XML:
<table TABLE_TYPE="table03"
xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" d3p1:table="table"
d3p1:trows="3" d3p1:cols="5" xmlns:d3p1="aid">
<cell d3p1:table="cell" d3p1:crows="1" d3p1:ccols="1"
d3p1:ccolwidth="50.0">
So the question is, is this a legal equivalent to the original InDesign XML?
If so, then fine, but if not, how can I get the DOM to correctly create
InDesign-compliant XML?
Many thanks in advance
Rob