Re: [xsl] replacing <!DOCTYPE> with <?xml-model?> in XSLT

Subject: Re: [xsl] replacing <!DOCTYPE> with <?xml-model?> in XSLT
From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 28 Jul 2022 11:23:21 -0000
Chris,

It might help to know that the DOCTYPE is not seen as part of the document
when parsed (the model), since its role is actually to say (partly) how to
parse it.

Hence you won't get a DOCTYPE unless you put one there, which XSLT can't
do, so it is done in serialization. (And you don't have to "remove" one.)

However, a PI is in the model, even before the root.

All this is easier to say than to say, of course. Part of the noise here is
in the tools you're using. I suggest making the XSLT work outside the
refactoring before installing it as a refactoring operation.

The XSLT itself is (you're right) pretty bone simple:

<xsl:template match="/">
  <xsl:processing-instruction> your PI </xsl:processing-instruction>
  <xsl:copy-of select="."/>
</xsl:template>

but your template matching "/*" should also work (I can't readily see why
it doesn't: maybe that's in the code you're not showing).

HTH! Wendell



On Thu, Jul 28, 2022 at 7:06 AM Chris Papademetrious
christopher.papademetrious@xxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi Martin,
>
>
>
> The processor is Saxon inside Oxygen; I am running this as an Oxygen
> refactoring operation.
>
>
>
> Oxygen compares the result against the input, then tries to minimize the
> diff footprint due to serialization differences. I suspect this
> bminimize-the-serialization-differencesb processing might be
responsible
> for me seeing a different behavior in Oxygen versus your fiddle.
>
>
>
> Thank you for having a look!
>
>
>
>    - Chris
>
>
>
>
>
> *From:* Martin Honnen martin.honnen@xxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
> *Sent:* Wednesday, July 27, 2022 5:25 PM
> *To:* xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> *Subject:* Re: [xsl] replacing <!DOCTYPE> with <?xml-model?> in XSLT
>
>
>
>
>
> On 27.07.2022 23:07, Chris Papademetrious
> christopher.papademetrious@xxxxxxxxxxxx wrote:
>
> If the <!DOCTYPE> gives you a problem when you fiddle with this, you could
> probably remove it and just play with the PI addition.
>
>
>
> Here is a fiddle
>
<https://urldefense.com/v3/__https:/martin-honnen.github.io/xml-workbench/?co
de=*3C*3Fxml*version*3D*221.0*22*encoding*3D*22UTF-8*22*3F*3E*0A*3Cxsl*3Astyl
esheet*xmlns*3Axsl*3D*22http*3A*2F*2Fwww.w3.org*2F1999*2FXSL*2FTransform*22*0
A*09xmlns*3Axs*3D*22http*3A*2F*2Fwww.w3.org*2F2001*2FXMLSchema*22*0A*09exclud
e-result-prefixes*3D*22*23all*22*0A*09version*3D*223.0*22*3E*0A*0A*3Cxsl*3Amo
de*on-no-match*3D*22shallow-copy*22*2F*3E*0A*0A*3Cxsl*3Atemplate*match*3D*22*
2F**A22*3E*0A*0A**B3Cxsl*3Aprocessing-instruction*name*3D*22xml-model*22*3Ehr
ef*3D*22urn*3Aoasis*3Anames*3Atc*3Adita*3Arng*3Atopic.rng*22*schematypens*3Dh
ttp*3A*2F*2Frelaxng.org*2Fns*2Fstructure*2F1.0*3C*2Fxsl*3Aprocessing-instruct
ion*3E*0A*0A**B3Cxsl*3Anext-match*2F*3E*0A*0A*3C*2Fxsl*3Atemplate*3E*0A**B0A*
3C*2Fxsl*3Astylesheet*3E*0A&input=*3C*21DOCTYPE*html*PUBLIC**A22-*2F*2FW3C*2F
*2FDTD*XHTML*1.0*Strict*2F*2FEN*22*0A**C22http*3A*2F*2Fwww.w3.org*2FTR*2Fxhtm
l1*2FDTD*2Fxhtml1-strict.dtd*22*3E*0A*3Chtml*xmlns*3D*22http*3A*2F*2Fwww.w3.o
rg*2F1999*2Fxhtml*22*lang*3D*22en*22*xml*3Alang*3D*22en*22*3E*0A*3Chead*3E*0A
**A3Ctitle*3EMy*page*title*3C*2Ftitle*3E*0A*3C*2Fhead*3E*0A*3Cbody*3E*0A*0A*3
C*2Fbody*3E*0A*3C*2Fhtml*3E*0A&code-type=XSLT&input-type=XML__;JSUrJSUlKyUlJS
UlJSUlKyUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUrJSUlJSUlJSUlKyUlJSo
lJSUlKyslJSslJSUlJSUlJSUlJSUlKyUlJSUlJSUlJSUlJSUrKyUlJSUlJSUlJSUlKyslJSUlJSUl
JSsrKyUlJSUlKysrJSUlJSsrKyUlJSUlJSUlJSUlJSslJSUlJSUlJSslJSUrJSUlJSUlJSUlKyUlK
yslJSUlJSUlJSUlJSUlJSUlJSUlJQ!!A4F2R9G_pg!dZgU2GDrnDKksoc6n4ku85GJS9IvG1l-Rh4
NCbUWZoTc4-NQgm0LwV1qsWuYh6KLjg-QzoVwwv1LAdnIpT0nNgEvLA3mL216lUkQbXU6afAqxuNd
jRH4$>
> using the XHTML DOCTYPE instead, as Saxon has that internally in its
> resolver data. The result I get is e.g.
>
>
>
> <?xml version="1.0" encoding="UTF-8"?><?xml-model
> href="urn:oasis:names:tc:dita:rng:topic.rng" schematypens=
> http://relaxng.org/ns/structure/1.0
>
<https://urldefense.com/v3/__http:/relaxng.org/ns/structure/1.0__;!!A4F2R9G_p
g!dZgU2GDrnDKksoc6n4ku85GJS9IvG1l-Rh4NCbUWZoTc4-NQgm0LwV1qsWuYh6KLjg-QzoVwwv1
LAdnIpT0nNgEvLA3mL216lUkQbXU6afAqxsy6afQ6$>?><html
> xmlns="http://www.w3.org/1999/xhtml";
>
<https://urldefense.com/v3/__http:/www.w3.org/1999/xhtml__;!!A4F2R9G_pg!dZgU2
GDrnDKksoc6n4ku85GJS9IvG1l-Rh4NCbUWZoTc4-NQgm0LwV1qsWuYh6KLjg-QzoVwwv1LAdnIpT
0nNgEvLA3mL216lUkQbXU6afAqxr80VPLX$>
> lang="en" xml:lang="en">
>    <head>
>       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
>       <title>My page title</title>
>    </head>
>    <body></body>
> </html>
>
> so the PI is where you want it.
>
> I don't see why you would need <xsl:output doctype-system=""/>, the input
> DOCTYPE is not copied as it is not part of the XSLT/XPath data model.
>
> Above link spelled out is
>
https://martin-honnen.github.io/xml-workbench/?code=%3C%3Fxml+version%3D%221.
0%22+encoding%3D%22UTF-8%22%3F%3E%0A%3Cxsl%3Astylesheet+xmlns%3Axsl%3D%22http
%3A%2F%2Fwww.w3.org%2F1999%2FXSL%2FTransform%22%0A%09xmlns%3Axs%3D%22http%3A%
2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%0A%09exclude-result-prefixes%3D%22%23al
l%22%0A%09version%3D%223.0%22%3E%0A%0A%3Cxsl%3Amode+on-no-match%3D%22shallow-
copy%22%2F%3E%0A%0A%3Cxsl%3Atemplate+match%3D%22%2F*%22%3E%0A%0A++%3Cxsl%3Apr
ocessing-instruction+name%3D%22xml-model%22%3Ehref%3D%22urn%3Aoasis%3Anames%3
Atc%3Adita%3Arng%3Atopic.rng%22+schematypens%3Dhttp%3A%2F%2Frelaxng.org%2Fns%
2Fstructure%2F1.0%3C%2Fxsl%3Aprocessing-instruction%3E%0A%0A++%3Cxsl%3Anext-m
atch%2F%3E%0A%0A%3C%2Fxsl%3Atemplate%3E%0A++%0A%3C%2Fxsl%3Astylesheet%3E%0A&i
nput=%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.0+Strict%2F%2FE
N%22%0A+++%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-strict.dtd%
22%3E%0A%3Chtml+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22+lang%3D%
22en%22+xml%3Alang%3D%22en%22%3E%0A%3Chead%3E%0A+%3Ctitle%3EMy+page+title%3C%
2Ftitle%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A
&code-type=XSLT&input-type=XML
>
<https://urldefense.com/v3/__https:/martin-honnen.github.io/xml-workbench/?co
de=*3C*3Fxml*version*3D*221.0*22*encoding*3D*22UTF-8*22*3F*3E*0A*3Cxsl*3Astyl
esheet*xmlns*3Axsl*3D*22http*3A*2F*2Fwww.w3.org*2F1999*2FXSL*2FTransform*22*0
A*09xmlns*3Axs*3D*22http*3A*2F*2Fwww.w3.org*2F2001*2FXMLSchema*22*0A*09exclud
e-result-prefixes*3D*22*23all*22*0A*09version*3D*223.0*22*3E*0A*0A*3Cxsl*3Amo
de*on-no-match*3D*22shallow-copy*22*2F*3E*0A*0A*3Cxsl*3Atemplate*match*3D*22*
2F**A22*3E*0A*0A**B3Cxsl*3Aprocessing-instruction*name*3D*22xml-model*22*3Ehr
ef*3D*22urn*3Aoasis*3Anames*3Atc*3Adita*3Arng*3Atopic.rng*22*schematypens*3Dh
ttp*3A*2F*2Frelaxng.org*2Fns*2Fstructure*2F1.0*3C*2Fxsl*3Aprocessing-instruct
ion*3E*0A*0A**B3Cxsl*3Anext-match*2F*3E*0A*0A*3C*2Fxsl*3Atemplate*3E*0A**B0A*
3C*2Fxsl*3Astylesheet*3E*0A&input=*3C*21DOCTYPE*html*PUBLIC**A22-*2F*2FW3C*2F
*2FDTD*XHTML*1.0*Strict*2F*2FEN*22*0A**C22http*3A*2F*2Fwww.w3.org*2FTR*2Fxhtm
l1*2FDTD*2Fxhtml1-strict.dtd*22*3E*0A*3Chtml*xmlns*3D*22http*3A*2F*2Fwww.w3.o
rg*2F1999*2Fxhtml*22*lang*3D*22en*22*xml*3Alang*3D*22en*22*3E*0A*3Chead*3E*0A
**A3Ctitle*3EMy*page*title*3C*2Ftitle*3E*0A*3C*2Fhead*3E*0A*3Cbody*3E*0A*0A*3
C*2Fbody*3E*0A*3C*2Fhtml*3E*0A&code-type=XSLT&input-type=XML__;JSUrJSUlKyUlJS
UlJSUlKyUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUrJSUlJSUlJSUlKyUlJSo
lJSUlKyslJSslJSUlJSUlJSUlJSUlKyUlJSUlJSUlJSUlJSUrKyUlJSUlJSUlJSUlKyslJSUlJSUl
JSsrKyUlJSUlKysrJSUlJSsrKyUlJSUlJSUlJSUlJSslJSUlJSUlJSslJSUrJSUlJSUlJSUlKyUlK
yslJSUlJSUlJSUlJSUlJSUlJSUlJQ!!A4F2R9G_pg!dZgU2GDrnDKksoc6n4ku85GJS9IvG1l-Rh4
NCbUWZoTc4-NQgm0LwV1qsWuYh6KLjg-QzoVwwv1LAdnIpT0nNgEvLA3mL216lUkQbXU6afAqxuNd
jRH4$>
>
> XSL-List info and archive
>
<https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__;!!A4F2
R9G_pg!dZgU2GDrnDKksoc6n4ku85GJS9IvG1l-Rh4NCbUWZoTc4-NQgm0LwV1qsWuYh6KLjg-Qzo
Vwwv1LAdnIpT0nNgEvLA3mL216lUkQbXU6afAqxinLndKt$>
>
> EasyUnsubscribe
>
<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsub/xsl-list/3380
743__;!!A4F2R9G_pg!dZgU2GDrnDKksoc6n4ku85GJS9IvG1l-Rh4NCbUWZoTc4-NQgm0LwV1qsW
uYh6KLjg-QzoVwwv1LAdnIpT0nNgEvLA3mL216lUkQbXU6afAqxmsCIT-J$>
> (by email)
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/174322> (by
> email <>)
>


--
...Wendell Piez... ...wendell -at- nist -dot- gov...
...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org...
...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...

Current Thread