Namespace declarations not output
Brought to you by:
tpsfadmin
When a DOM is serialised, any namespace prefixes will
not have a corresponding namespace declaration. No
attempt is made in TXpNode.noomGetXpDocument to add
such a declaration.
This means that all XML with namespace prefixes is
output in an invalid (non-well-formed) format.
Logged In: YES
user_id=966026
On further investigation, this is only the case in something
like an XSL-FO stylesheet, where the "fo" namespace is
declared at the head of the stylesheet document, but not on
the individual XSL-FO elements that it outputs.
A workaround is to add an explicit namespace declaration to
the <fo:root> element in the stylesheet: this will then
appear in the output.
Logged In: YES
user_id=966026
In fact the problem is specific to "fo" instructions, which
are treated as XSL instructions rather than ordinary literal
result elements and so miss out on the namespace processing.
This can be fixed by adding the marked lines to
TXpFilterText.XslProcessorFormatObject:
...
if (aFormatObject.FormatObjectType = FO_ROOT) then begin
FResultTree.Document.AppendChild(oNode);
if (not (oNode as
TXpElement).HasAttribute(XpsXmlns+':fo')) then {!!.60 rbl
bug 1249734}
(oNode as TXpElement).SetAttribute(XpsXmlns+':fo',
XpsXSLFOURI); {!!.60 rbl bug 1249734}
FCurElement := TXpElement(oNode);
end else
{ Are we creating the root element? }
if (FCurElement = nil) then begin
{ Yes. Create it & make it to the document element. }
oRoot := FResultTree.Document.CreateElement(XpsRoot);
FResultTree.Document.AppendChild(oRoot);
oRoot.SetAttribute(XpsXmlns+':fo', XpsXSLFOURI);
{!!.60 rbl bug 1249734}
FCurElement := oRoot;
...
Logged In: YES
user_id=966026
... this further assumes that you have declared the constant
XpsXSLFOURI in XpXSLCon.pas (e.g. at the end of "Misc strings"):
XpsXSLFOURI =
'http://www.w3.org/1999/XSL/Format'; {!!.60 rbl}