| hardywang |
| Newbie |
|
|
|
|
| None Specified |
|
| Monday, May 12, 2008 |
| Thursday, February 18, 2010 7:03:00 PM |
8 [0.04% of all post / 0.00 posts per day] |
|
that wrote:You can change the source schema to use a string instead of an integer. Then MapForce will not try to cast it to numeric on reading.
Thanks, I cannot change any of the schema file.
Anyway, I found a way that in MapForce I add function to convert integer to string first, so the generated XSLT will be
Code:<?xml version="1.0" encoding="UTF-8"?> <!-- This file was generated by Altova MapForce 2008r2 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. https://www.altova.com/mapforce--> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs xsi xsl"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/Root1"> <Root2> <xsl:for-each select="Phone"> <Phone> <xsl:value-of select="string(.)"/> </Phone> </xsl:for-each> </Root2> </xsl:template> </xsl:stylesheet>
|
Hi all, I generated XSLT from Altova MapForce and it seems that different Xml engine will treat it in a slightly different way.
I use followiing sample to describe the problem we currently have:
Source XSD:
Code:<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Root1"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="Phone" type="xs:integer"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
Destination XSD:
Code:<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Root2"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="Phone" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
Thare is only 1 element in each, the difference is that source phone number is integer data type, and destination phone number is string data type.
The XSLT generated from MapForce
Code:<?xml version="1.0" encoding="UTF-8"?> <!-- This file was generated by Altova MapForce 2008r2 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. https://www.altova.com/mapforce--> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs xsi xsl"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/Root1"> <Root2> <xsl:for-each select="Phone"> <xsl:variable name="Vvar11_Phone_integer" select="number(.)"/> <Phone> <xsl:value-of select="string($Vvar11_Phone_integer)"/> </Phone> </xsl:for-each> </Root2> </xsl:template> </xsl:stylesheet>
The input Xml is
Code:<?xml version="1.0" encoding="UTF-8"?> <!--Sample XML file generated by XMLSpy v2008 rel. 2 (https://www.altova.com)--> <Root1 xsi:noNamespaceSchemaLocation="test1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Phone>2817956177</Phone> </Root1>
I used Altova XmlSpy 2008, Altova MapForce 2008, .Net Framework 3.5 code to transform the Xml above and I could get expected result
Code:<?xml version="1.0" encoding="UTF-8"?> <Root2> <Phone>2817956177</Phone> </Root2>
But meanwhile, some Java framework, XML Copy Editor from http://xml-copy-editor.sourceforge.net/ will generate result
Code:<?xml version="1.0" encoding="UTF-8"?> <Root2> <Phone>2.817956177e+009</Phone> </Root2>
The problem is the XSLT function <xsl:variable name="Vvar11_Phone_integer" select="number(.)"/>, if it is changed to <xsl:variable name="Vvar11_Phone_integer" select="string(.)"/> then both sides work.
Is there a way I can force MapForce to generate the function to take care the Imcompatibility issue?
Thanks Hardy
|
I would like to insert current date somewhere in my HTML, how can I do it in StyleVision 2008?
Thanks Hardy
|
vlad wrote:Simply right-click the Name template, select "Edit XPath Filter" and enter your XPath statement
@Part="first"
Hi,
Thanks for your response, I am running 2008 version of StyleVision, I don't see such a menu item from right-click.
Do I have to upgrade to 2010 version?
Thanks Hardy
|
Hi all,
I have a Xml like:
<Customer> <Name Part="first">John</Name> <Name Part="last">Smith</Name> </Customer>
Now I create a content inside HTML "[Name>(content)<Name]" which points to Customer/Name. In the output HTML I always can see "John Smith".
How about I just want first name as output, what do I do to filter only Customer/Name[@Part="first"] inside a content?
Thanks Hardy
|
I downloaded a XSD with following lines inside, XmlSpy complains about the red part saying "value is not a valid XML regular expression".
I tried that expression in C# it works fine. Anybody can tell me why?
<xs:simpleType name="ComponentGuid"> <xs:annotation> <xs:documentation>Values of this type will look like: "01234567-89AB-CDEF-0123-456789ABCDEF" or "{01234567-89AB-CDEF-0123-456789ABCDEF}", but also allows "PUT-GUID-HERE" for use in examples. It's also possible to have an empty value "".</xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:pattern value="[{(]?[0-9A-Fa-f]{8}\-?[0-9A-Fa-f]{4}\-?[0-9A-Fa-f]{4}\-?[0-9A-Fa-f]{4}\-?[0-9A-Fa-f]{12}[})]?|PUT\-GUID\-(?:\d+\-)?HERE|([!$])(\(var|\(loc|\(wix)\.[_A-Za-z][0-9A-Za-z_.]*\)|\*|^$"/> </xs:restriction> </xs:simpleType>
|
szopen wrote:When you double-click on function to edit it, there are two buttons, one on the left on the image, which returns you to main mapping, and there's second button, far on the right side, it's name is "Erase", and this one deletes your function. Here's image:  Hope this hepls Best regards :)
Unfortunately for the imported functions there is no such a button. For the functions created inside this mapping I can delete without problem.
Hardy
|
Hi all,
I created a new mapping project and imported some functions from other mfd file. Now the imported ones just sit in my libraries, I neither could edit them nor delete them.
What can I do to remove them?
Hardy
|
|