version 1.13, 2007/01/11 13:17:28
|
version 1.14, 2007/01/15 16:06:12
|
Line 110 void RegisterURLs(Document doc, Element
|
Line 110 void RegisterURLs(Document doc, Element
|
void CreateInstance(char *templatePath, char *instancePath) |
void CreateInstance(char *templatePath, char *instancePath) |
{ |
{ |
#ifdef TEMPLATES |
#ifdef TEMPLATES |
Document doc = 0; |
Document doc = 0; |
DocumentType docType; |
DocumentType docType; |
ThotBool alreadyViewing = FALSE; |
ElementType elType; |
int alreadyOnDoc = 0; |
Element root, title, text; |
|
char *s; |
|
int alreadyOnDoc = 0; |
|
ThotBool alreadyViewing = FALSE; |
|
|
XTigerTemplate t = (XTigerTemplate)Dictionary_Get (Templates_Dic, templatePath); |
XTigerTemplate t = (XTigerTemplate)Dictionary_Get (Templates_Dic, templatePath); |
if (t == NULL) |
if (t == NULL) |
Line 121 void CreateInstance(char *templatePath,
|
Line 124 void CreateInstance(char *templatePath,
|
return; |
return; |
|
|
doc = GetTemplateDocument (t); |
doc = GetTemplateDocument (t); |
docType = DocumentTypes[doc]; |
|
while (alreadyOnDoc < DocumentTableLength-1 && !alreadyViewing) |
while (alreadyOnDoc < DocumentTableLength-1 && !alreadyViewing) |
{ |
{ |
alreadyOnDoc++; |
alreadyOnDoc++; |
Line 132 void CreateInstance(char *templatePath,
|
Line 134 void CreateInstance(char *templatePath,
|
if (!TtaPrepareUndo (doc)) |
if (!TtaPrepareUndo (doc)) |
{ |
{ |
TtaOpenUndoSequence (doc, NULL, NULL, 0, 0); |
TtaOpenUndoSequence (doc, NULL, NULL, 0, 0); |
RegisterURLs (doc, TtaGetRootElement(doc)); |
root = TtaGetRootElement(doc); |
|
elType = TtaGetElementType (root); |
|
// get the target document type |
|
s = TtaGetSSchemaName (elType.ElSSchema); |
|
if (strcmp (s, "HTML") == 0) |
|
docType = docHTML; |
|
else if (strcmp (s, "SVG") == 0) |
|
docType = docSVG; |
|
else if (strcmp (s, "MathML") == 0) |
|
docType = docMath; |
|
else |
|
docType = docXml; |
|
|
|
RegisterURLs (doc, root); |
SetRelativeURLs (doc, instancePath); |
SetRelativeURLs (doc, instancePath); |
|
|
switch (docType) |
switch (docType) |
{ |
{ |
case docSVG : |
case docSVG: |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, "SVGT"); |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, "SVGT"); |
break; |
break; |
case docMath : |
case docMath: |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, "MathMLT"); |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, "MathMLT"); |
break; |
break; |
case docHTML : |
case docHTML: |
|
// Initialize the document title |
|
elType.ElTypeNum = HTML_EL_TITLE; |
|
title = TtaSearchTypedElement (elType, SearchInTree, root); |
|
text = TtaGetFirstChild (title); |
|
while (text) |
|
{ |
|
elType = TtaGetElementType (text); |
|
if (elType.ElTypeNum == HTML_EL_TEXT_UNIT && Answer_text[0] != EOS) |
|
{ |
|
TtaSetTextContent (text, (unsigned char*)Answer_text, |
|
TtaGetDefaultLanguage (), doc); |
|
text = NULL; |
|
} |
|
else if ((elType.ElTypeNum == Template_EL_useEl || |
|
elType.ElTypeNum == Template_EL_useSimple) && |
|
!strcmp (TtaGetSSchemaName (elType.ElSSchema), "Template")) |
|
// Ignore the template use element |
|
text = TtaGetFirstChild (text); |
|
else |
|
// Look for the first text child |
|
TtaNextSibling (&text); |
|
} |
if (TtaGetDocumentProfile(doc)==L_Xhtml11 || TtaGetDocumentProfile(doc)==L_Basic) |
if (TtaGetDocumentProfile(doc)==L_Xhtml11 || TtaGetDocumentProfile(doc)==L_Basic) |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, "HTMLT11"); |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, "HTMLT11"); |
else |
else |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, "HTMLTX"); |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, "HTMLTX"); |
break; |
break; |
default : |
default: |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, NULL); |
TtaExportDocumentWithNewLineNumbers (doc, instancePath, NULL); |
break; |
break; |
} |
} |