xml - How to copy exactly the Doctype, if the Doctype or the included entity isn't known? -


my challenge today find out how copy doctype of source document. ok first source:

<?xml version='1.0' encoding='iso-8859-1'?> <!doctype xmlblock system "/dtd/xmlblock.dtd" [ <!entity change '<issue>  <version>version no: 98765432</version>    <purpose><![cdata[      main purpose       - things       - fix issues ]]>    </purpose>  </issue> '>]> <xmlblock>   <title>xml stuff</title>   <content>demotext</content> </xmlblock> 

as can see there internal entity version no, changes every time. want catch number decide wrapper needed. xslt:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"  version="1.0">   <xsl:output doctype-system="/dtd/xmlblock.dtd" />   <xsl:template match ="/" >       <xsl:choose>         <xsl:when test="&change;/issue/version &lt; 9000000">           <xmlblock>             <red>               <xsl:copy-of select="*" />             </red>           </xmlblock>         </xsl:when>         <xsl:otherwise>           <xmlblock>             <green>                <xsl:copy-of select="*" />             </green>           </xmlblock>         </xsl:otherwise>       </xsl:choose>     </xsl:template>   </xsl:stylesheet> 

but &change; isn't resolved because not part of xslt. how can solve issue, or impossible? kind regards

markus

the xslt not have declaration of entity &changed; not valid xml, know. stylesheet fixed, variable part solely transformed document.

the parsed xml seen transformer not have information version value. seems pretty useless declare entity.

seems version number better stored in processing instruction:

<?xml version="1.0"?> <!doctype xmlblock system "/dtd/xmlblock.dtd"]> <?version 98765432?> <xmlblock> ... 

in stylesheet easy access version:

<xsl:variable name="version" select="/processing-instruction('version')"/> 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -