Subject: Re: [xsl] Preserving Graphic Entities From: "Lizzi, Vincent vincent.lizzi@xxxxxxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 13 Jul 2022 22:54:07 -0000 |
Hi Rick, The DOCTYPE is usually removed during parsing of the XML, but it is possible to work around that and get access to the DOCTYPE. This might do what you are asking: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"> <xsl:output omit-xml-declaration="yes"/> <xsl:mode on-no-match="shallow-copy"/> <xsl:template match="/Document"> <xsl:variable name="unparsed" select="unparsed-text(base-uri())"/> <xsl:variable name="start" select="substring-before($unparsed, '<Document')"/> <xsl:value-of select="$start" disable-output-escaping="yes"/> <xsl:next-match/> </xsl:template> </xsl:stylesheet> This essentially reads the XML (assuming the XML is in a file) as plain text and outputs a copy of everything that appears before the root element, then does an identity transform. The matching in substring-before is fragile because the root element <Document not be the first thing in the file that matches this sequence of characters, so you might need to adjust the matching. Depending on your needs you could make a specific match that works for your documents. If you need a generalized approach that works for any XML document it would need to follow the rules of the grammar defined in the W3C XML Recommendation. Kind regards, Vincent _____________________________________________ Vincent M. Lizzi Head of Information Standards | Taylor & Francis Group vincent.lizzi@xxxxxxxxxxxxxxxxxxxx<mailto:vincent.lizzi@xxxxxxxxxxxxxxxxxxxx> Information Classification: General From: rick@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, July 13, 2022 4:16 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Preserving Graphic Entities Hello All, I am sorry if this is an old question, but when I export to XML, I am getting graphic entities. I need to preserve these when I transform the file with XSLT 3. Is there a built-in way to do this or some kind of realistic hack? Below is a sample before transformation. Thank you very much. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Document SYSTEM "file:///C:/Users/rick/AppData/Roaming/Adobe/FrameMaker/16/Orion-graphics/Gra phics.dtd" [ <!NOTATION jpeg PUBLIC ""> <!ENTITY abc123 SYSTEM "3753.jpeg" NDATA jpeg> <!ENTITY SingleImportedImage1 SYSTEM "11721.jpeg" NDATA jpeg> ]> <Document> <Paragraph>Sample for testing graphics export to XML.</Paragraph> <Paragraph>Single imported image:</Paragraph> <Graphic boardno="abc123" reprowid="2.567in" reprodep="3.367in"/> <Paragraph>Single imported image:</Paragraph> <Graphic boardno="SingleImportedImage1" reprowid="2.567in" reprodep="3.367in"/> </Document> Rick XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<http://lists.mulberrytech.com/unsub/xsl-list/194671> (by email<>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Preserving Graphic Entiti, Norm Tovey-Walsh ndw | Thread | [xsl] Lesson Learned: Don’t write , Roger L Costello cos |
Re: [xsl] Preserving Graphic Entiti, Wendell Piez wapiez@ | Date | Re: [xsl] Preserving Graphic Entiti, Norm Tovey-Walsh ndw |
Month |