Author |
Message
|
telus |
Posted: Wed Nov 28, 2012 7:31 am Post subject: |
|
|
Apprentice
Joined: 01 Nov 2012 Posts: 26
|
My bad I have gave the wrong error .
The actual error will be :
item 'xsl:deceeasedDate' can not be mapped because it is the part of the derived type item 'xsl-payload xsi:type=''xsl:xxxxtRequest".XSLT1 does not support xsi:type.
Thanks |
|
Back to top |
|
 |
kimbert |
Posted: Wed Nov 28, 2012 12:49 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Telus: I think the following statements are true. Do you agree?
a) An HL7 v3 document is just an ordinary XML document
b) XSLT v.0 can process any ( well-formed ) XML document
c) XSLT 1.0 is not very good at processing documents that use namespaces ( you have to put the namespace prefixes into the XPath expressions )
d) HL7 v3 always uses namespaces, and uses most of the advanced features of XML Schema.
e) In an ideal world, XSLT 2.0 is better than XSLT 1.0, especially if processing documents that have namespaces.
Please point out anything that I have missed. |
|
Back to top |
|
 |
goffinf |
Posted: Wed Nov 28, 2012 1:13 pm Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
kimbert wrote: |
Telus: I think the following statements are true. Do you agree?
a) An HL7 v3 document is just an ordinary XML document
b) XSLT v.0 can process any ( well-formed ) XML document
c) XSLT 1.0 is not very good at processing documents that use namespaces ( you have to put the namespace prefixes into the XPath expressions )
d) HL7 v3 always uses namespaces, and uses most of the advanced features of XML Schema.
e) In an ideal world, XSLT 2.0 is better than XSLT 1.0, especially if processing documents that have namespaces.
Please point out anything that I have missed. |
Well (c) is to do with XPath (1.0 in this case) and is not specific to XSLT, in fact it's common practice to use prefix bindings in almost all languages.
XSLT2 is certainly a more powerful implementation but again not especially because of namespace support. I suspect it would be more useful because of the ability to use strong typing, but since XSLT2 is not an option, that's moot.
I would say the most important idea to grasp is your point (b). I haven't seen any evidence yet that the OPs document can't be processed, regardless of whether run-time type assertions are used or not.
Telus can you post part of your XML instance document and provide an idea of how you want to process it. If is would help I can direct you to an XSLT forum that can help with any XSLT specific questions. |
|
Back to top |
|
 |
telus |
Posted: Wed Nov 28, 2012 2:20 pm Post subject: |
|
|
Apprentice
Joined: 01 Nov 2012 Posts: 26
|
Here is the part of XSLT.
Quote: |
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file was generated by Altova MapForce 2013
YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
Refer to the Altova MapForce Documentation for further details.
http://www.altova.com/mapforce
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://www.xyz.ca/message/XML" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fn="http://www.w3.org/2005/xpath-functions" exclude-result-prefixes="xs fn">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="var1_resultof_cast" as="xs:string" select="xs:string(fn:true())"/>
<xsl:variable name="var2_KLMMessage" as="node()?" select="ns0:KLMMessage"/>
<xsl:variable name="var7_resultof_map" as="node()*">
<xsl:for-each select="$var2_KLMMessage">
<xsl:variable name="var6_resultof_filter" as="node()*">
<xsl:for-each select="ns0:Body/ns0:Payload">
<xsl:variable name="var4_" as="node()" select="."/>
<xsl:variable name="var3_resultof_map" as="xs:boolean*">
<xsl:for-each select="@xsi:type">
<xsl:sequence select="(fn:resolve-QName(fn:string(.), $var4_) = xs:QName('ns0:MyRequestBody'))"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="var5_resultof_any" as="xs:boolean" select="fn:exists($var3_resultof_map[.])"/>
<xsl:if test="$var5_resultof_any">
<xsl:sequence select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="$var6_resultof_filter">
<xsl:attribute name="value" select="xs:string(xs:date(fn:string(ns0:RequestEffectiveTime)))"/>
</xsl:for-each>
</xsl:for-each> |
I got error that xsi type not supported by XSLT 1
But when I generated the same in the XSLT2 it will go.[/quote] |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Nov 28, 2012 4:15 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
telus wrote: |
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<!-- ... -->
<xsl:stylesheet version="2.0" ...>
...
<xsl:variable ... as=.../>
...
<xsl:for-each select="@xsi:type">
<xsl:sequence select="(fn:resolve-QName(fn:string(.), $var4_) = xs:QName('ns0:MyRequestBody'))"/>
</xsl:for-each>
...
<xsl:attribute ... select=.../>
... |
|
This is not an XSLT v1.0 stylesheet:- the xsl:stylesheet "version" attribute should not be "2.0"
- the xsl:variable element should not have an "as" attribute
- there shouldn't be an xsl:sequence element
- the xsl:attribute element should not have a "select" attribute
- the XSLT v1.0 stylesheet should probably not be calling XPath v2.0 functions
telus wrote: |
I got error that xsi type not supported by XSLT 1 |
Got error from where? What was it that generated the error? |
|
Back to top |
|
 |
telus |
Posted: Wed Nov 28, 2012 4:19 pm Post subject: |
|
|
Apprentice
Joined: 01 Nov 2012 Posts: 26
|
This is XSLT 2.0 not 1.0.
The error I have already posted. Altova not generate the XSLT1.0 as there are errors which I have posted in the previous messages. |
|
Back to top |
|
 |
goffinf |
Posted: Thu Nov 29, 2012 1:18 am Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
telus wrote: |
This is XSLT 2.0 not 1.0.
The error I have already posted. Altova not generate the XSLT1.0 as there are errors which I have posted in the previous messages. |
Right, so you are using Altova's MapForce product to map between one (or more) input XSDs to an output and then asking for the XSLT that it generates for you (typically not the best quality in my experience). And presumably one of your XSDs is using derived types hence the need for the run-time (xsi:type) type assertion in the example instance you fed it.
However all of that is to do with MapForce, nothing to do with Message Broker's implementation of XSLT. just because MapForce can't provide you with an XSLT 1.0 version of the transformation, doesn't mean that it can't be done and doesn't mean that MB is in some way to blame.
It certainly *is * possible to select an element from an XML instance document which uses the xsi:type attribute value as part of the XPath predicate, all you need is to make sure that you bind the xsi prefix to its namespace .... something like (xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance") should do it.
If the transformation you are attempting isn't too complex, maybe you can consider writing the XSLT 1.0 version yourself, you'll probably find you can make it somewhat more optimised than the auto generated stuff.
If you are struggling with the XPath, then post part of your XML instance and state what you are trying to select. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 29, 2012 2:25 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Thanks Fraser - I agree with all of that. |
|
Back to top |
|
 |
rekarm01 |
Posted: Thu Nov 29, 2012 2:27 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
telus wrote: |
This is XSLT 2.0 not 1.0. |
... which the broker doesn't support.
telus wrote: |
The error I have already posted. Altova not generate the XSLT1.0 as there are errors which I have posted in the previous messages. |
So, it's the Altova MapForce XSLT1 code generating engine that doesn't support xsi:type. The Altova User Forum (or Altova support) might be a better place to ask about that. Alternatively, use some other mapping tool to generate an XSLT 1.0 stylesheet, or manually create one.
But, is XSLT even necessary? The broker offers plenty of other transformation nodes, such as the Mapping node, or Compute node, which may be easier to work with. |
|
Back to top |
|
 |
|