Richard,

>> I have used LyX on and off for many years and, working 
>> sporadically with TLDP [0], I have handled a few documents that 
>> were written in LyX.  Thank you to the LyX team for your work on 
>> this tool over the years.
>>
>> I have two questions today, after examining the DocBook XML 
>> output from the 2.2.x series.
>>
>> Question 1
>> ----------
>> Is it possible to change the public identifier for the DocBook 
>> XML 4.2 output processor to use:
>>
>>   -//OASIS//DTD DocBook XML V4.2//EN   # -- my suggestion
>>   -//OASIS//DTD DocBook XML//EN        # -- current identifier [1]
>>
>> I have checked the XML catalogs on several different platforms 
>> and I cannot find a reference to the latter identifier, and I 
>> think it may simply be an oversight.  The system identifier (the 
>> URL [2]) is correct.
>
>This code goes way, way back to 2004. It seems to have been 
>introduced at 33243f700. It appears that the one without "V4.2" was 
>meant to be for XML, whereas the other one was meant to be for 
>SGML. It's easy enough to change it so we output the same thing 
>both times, but let me cc José and see if he has any thoughts.

OK, great!  And thank you for the quick reply!

The SGML public identifier (on line 2032) is correct.

  -//OASIS//DTD DocBook V4.2//EN     # -- for DocBook SGML at V4.2
  -//OASIS//DTD DocBook XML V4.2//EN # -- for DocBook XML at V4.2

>> Question 2
>> ----------
>> When running the DocBook XML export function, I discover that not 
>> all text with '&' is not getting properly escaped with the XML 
>> entity &.  There's clearly code to handle that:
>>
>>   http://www.lyx.org/trac/browser/lyxgit/src/sgml.cpp#L46
>>
>> To the best of my ability I traced down a case of a Hyperlink 
>> whose text is not properly XML-escaped.  I think this is the 
>> line, but I'm not certain:
>>
>>   http://www.lyx.org/trac/browser/lyxgit/src/insets/InsetHyperlink.cpp#L235
>>
>>   int InsetHyperlink::docbook(odocstream & os, OutputParams const &) const
>>   {
>>           os << "<ulink url=\""
>>              << subst(getParam("target"), from_ascii("&"), 
>> from_ascii("&amp;"))
>>              << "\">"
>>              << getParam("name")
>>              << "</ulink>";
>>           return 0;
>>   }
>>
>> I think that getParam("name") also needs to be run through 
>> sgml::escapeString.
>
>Yes, that seems right. Since you have the git repo, can you make 
>this change and test it? I'm not sure anyone on the development 
>team actually uses the docbook classes.

Yes, I can and I yes it works.  I have attached the patch.  I have 
never touched C++ before, so this is just the dumbest thing I could 
suggest, though it seems to do the trick.

Best regards,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 2b2660e..94e94fa 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2026,7 +2026,7 @@ void Buffer::writeDocBookSource(odocstream & os, string const & fname,
 		if (! tclass.class_header().empty())
 			os << from_ascii(tclass.class_header());
 		else if (runparams.flavor == OutputParams::XML)
-			os << "PUBLIC \"-//OASIS//DTD DocBook XML//EN\" "
+			os << "PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\" "
 			    << "\"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\"";;
 		else
 			os << " PUBLIC \"-//OASIS//DTD DocBook V4.2//EN\"";
diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp
index 54f1f2c..039f553 100644
--- a/src/insets/InsetHyperlink.cpp
+++ b/src/insets/InsetHyperlink.cpp
@@ -22,6 +22,7 @@
 #include "LaTeXFeatures.h"
 #include "OutputParams.h"
 #include "output_xhtml.h"
+#include "sgml.h"
 
 #include "support/docstream.h"
 #include "support/FileName.h"
@@ -232,7 +233,7 @@ int InsetHyperlink::docbook(odocstream & os, OutputParams const &) const
 	os << "<ulink url=\""
 	   << subst(getParam("target"), from_ascii("&"), from_ascii("&amp;"))
 	   << "\">"
-	   << getParam("name")
+	   << sgml::escapeString(getParam("name"))
 	   << "</ulink>";
 	return 0;
 }

Reply via email to