MARX#51619: Ondersteunen MessageService 3.0/3.1

svn path=/Website/branches/v2017.2/; revision=36525
This commit is contained in:
Marcel Bourseau
2018-01-09 15:47:07 +00:00
parent 61f337968b
commit dc668a4971

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" version="1.0">
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:decimal-format name="european" decimal-separator="," grouping-separator="."/>
@@ -90,6 +90,137 @@
</xsl:if>
</xsl:template>
<!-- Parse XML-String to XML-object -->
<xsl:template name="parseXml">
<xsl:param name="text"/>
<xsl:param name="default_namespace"/>
<xsl:choose>
<xsl:when test="contains($text, '&gt;')">
<xsl:variable name="topLevelTag">
<xsl:call-template name="getTopLevelTag">
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="openingTag">
<xsl:value-of select="$topLevelTag"/>
</xsl:variable>
<xsl:variable name="tagName">
<xsl:call-template name="getTopLevelTagName">
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="closingTag">
<xsl:value-of select="concat('&lt;/',$tagName,'&gt;')"/>
</xsl:variable>
<xsl:variable name="firstNode">
<xsl:if test="not(contains($topLevelTag,'/&gt;'))">
<xsl:value-of select="substring-before(substring-after($text,$openingTag),$closingTag)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="afterFirstNode">
<xsl:choose>
<xsl:when test="not(contains($topLevelTag,'/&gt;'))">
<xsl:value-of select="substring-after($text,concat($firstNode,$closingTag))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-after($text,$topLevelTag)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="{$tagName}" namespace="{$default_namespace}">
<xsl:call-template name="createAttributes">
<xsl:with-param name="text" select="$topLevelTag"/>
</xsl:call-template>
<xsl:call-template name="parseXml">
<xsl:with-param name="text" select="$firstNode"/>
<xsl:with-param name="default_namespace" select="$default_namespace"/>
</xsl:call-template>
</xsl:element>
<xsl:call-template name="parseXml">
<xsl:with-param name="text" select="$afterFirstNode"/>
<xsl:with-param name="default_namespace" select="$default_namespace"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="getTopLevelTagName">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="contains($text, '&gt;')">
<xsl:variable name="tagWithAttributesWithoutEnd">
<xsl:value-of select="substring-before($text, '&gt;')"/>
</xsl:variable>
<xsl:variable name="tagWithAttributesWithoutBegining">
<xsl:value-of select="substring-after($tagWithAttributesWithoutEnd, '&lt;')"/>
</xsl:variable>
<xsl:variable name="tagName">
<xsl:choose>
<xsl:when test="contains($tagWithAttributesWithoutBegining,' ')">
<xsl:value-of
select="substring-before($tagWithAttributesWithoutBegining, ' ')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tagWithAttributesWithoutBegining"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="$tagName"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="getTopLevelTag">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="contains($text, '&gt;')">
<xsl:variable name="tagWithAttributesWithoutEnd">
<xsl:value-of select="substring-before($text, '&gt;')"/>
</xsl:variable>
<xsl:value-of select="concat($tagWithAttributesWithoutEnd,'&gt;')"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="createAttributes">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="contains($text, '=&quot;')">
<xsl:variable name="attributeName">
<xsl:value-of select="substring-before(substring-after($text,' '),'=&quot;')"/>
</xsl:variable>
<xsl:message>
<xsl:value-of select="$text"/>
</xsl:message>
<xsl:variable name="attributeValue">
<xsl:value-of select="substring-before(substring-after($text,concat($attributeName,'=&quot;')),'&quot;')"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains($attributeName, 'xmlns')">
<xsl:variable name="ns_prefix"><xsl:value-of select="substring-after($attributeName,'xmlns:')"/></xsl:variable>
<xsl:choose>
<xsl:when test="$ns_prefix != ''">
<xsl:variable name="dummy"><xsl:element name="{$ns_prefix}:dummy" namespace="{$attributeValue}"/></xsl:variable>
<xsl:copy-of select="msxml:node-set($dummy)//namespace::*"/>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="contains($attributeName, 'noNamespaceSchemaLocation')">
<xsl:variable name="ns_prefix"><xsl:value-of select="substring-before($attributeName,':noNamespaceSchemaLocation')"/></xsl:variable>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="{$attributeName}"><xsl:value-of select="$attributeValue"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="createAttributes">
<xsl:with-param name="text" select="substring-after($text,concat($attributeName,'=&quot;',$attributeValue,'&quot;'))"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>