Hi Aspose Team,
I am doing the documnt styling using ASPOSE. Here i am pasting the piece of code doing the job. But i am experiencing one issue i have described below. PF the attached sample documnt(sample1.docx) for input and the expected output i have mentioned below. Here i am attching the style mapper file for your reference to get the xml output in a specific format as i have mentioned the output.
private XmlDocument docToXml(Document doc, string metaData)
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode documentNode;
XmlNode LevelOneNode = null;
XmlNode LevelTwoNode = null;
XmlNode LevelThreeNode = null;
XmlNode LevelFourNode = null;
xmlDoc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><document></document>");
documentNode = xmlDoc.SelectSingleNode("document");
documentNode.InnerXml = metaData;
StyleMapper styleMap = new StyleMapper(AppPath + "stylemapping.xml");
TextReplaceMapper textMap = new TextReplaceMapper(AppPath + "textmapping.xml");
xmlDoc.PreserveWhitespace = true;
XmlElement pageNode;
pageNode = addPage(xmlDoc);
documentNode.AppendChild(pageNode);
int currentPageNumber = int.Parse(pageNode.Attributes["id"].Value);
//AppLog.trace("processing page 1");
NodeCollection paras = doc.GetChildNodes(NodeType.Paragraph, true);
foreach (Paragraph para in paras)
{
string DocText = para.Range.Text;
if (DocText[0] == 0xC)
{
DocText = DocText.Substring(1, DocText.Length - 1);
pageNode = addPage(xmlDoc);
currentPageNumber = int.Parse(pageNode.Attributes["id"].Value);
}
DocText = ConvertCodes(DocText);
DocText = DocText.Trim();
if (DocText != string.Empty)
{
string StyleName;
XmlNode DocElement = null;
DocText = textMap.DoReplacment(DocText);
Style ws = para.ParagraphFormat.Style;
StyleName = (ws == null ? "normal" : ws.Name);
}
}
}
return xmlDoc;
}
Output:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<document>
<meta>
<timestamp>20040119130000</timestamp>
<published>20040119130000</published>
<expires />
<plan>45000</plan>
<source>AAROW</source>
<userid>a259593</userid>
</meta>
<page id="1">
<p>PARTICIPATING IN YOUR plan
<PlanIntro>You can measure the amount of time that a driver spends in deferred procedure calls (DPCs) and interrupt service. routines (ISRs) by tracing these events in the Windows kernel. This information will help you to minimize the time. For additional information about your Plan visit www.example.com</PlanIntro>
<PlanIntro>
When am I eligible for the Plan?
<p>You are eligible to participate in the Plan if:
<bullet>you are eligible to xyx</bullet>
<bullet>you are a Indian citizen</bullet>
<p>You can measure the amount of time that a driver spends in deferred procedure calls.
<p>How do I enroll in the Plan?
<p>You can measure the amount of time that a driver spends in deferred procedure calls (DPCs) and interrupt service. routines (ISRs) by tracing these events in the Windows kernel. enroll.
<p>You can measure the amount of time that a driver spends in deferred procedure calls (DPCs) and interrupt service. routines (ISRs) by tracing these events in the Windows kernel. enroll. You can measure the amount of time that a driver spends in deferred procedure calls (DPCs) and interrupt service. routines (ISRs) by tracing these events in the Windows kernel. enroll. You can measure the amount of time that a driver spends in deferred procedure calls (DPCs) and interrupt service. routines (ISRs) by tracing these events in the Windows kernel. enroll. You can measure the amount of time that a driver spends in deferred procedure calls (DPCs) and interrupt service. routines (ISRs) by tracing these events in the Windows kernel. enroll.
</PlanIntro>
<Question title="When is my enrollment effective?">
<p>You can measure the amount of time that a driver spends in deferred procedure calls (DPCs) and interrupt service. routines (ISRs) by tracing these events in the Windows kernel. enroll.
</Question>
</page>
<page id="2" />
</document>
The issue Issue :
Why two same question-statement appearing in a two different way. e.g
<P style="MARGIN: 0in 0in 0pt" class=FPTagIndicator>When am I eligible for the Plan? is appearing as <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<PlanIntro>
When am I eligible for the Plan? (The style name is FP_Tag Indicator)
and the
When is my enrollment effective? is appearing as
<Question title="When is my enrollment effective?"> (the style name is FP_Body Text Bold 10_Avenir)
that means aspose is taking both the paragraph style in a different way. The style name is different, so whenever i am applying the stylemapper.xml file i am getting diffent output. Please assist.