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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -