|
next
|
 Subject: Newbie: HELP! How to do simple transforms and defaults visually in Stylus ? Author: Brian McNamara Date: 25 Jan 2005 05:02 PM
|
Dear Stylus,
HELP!
I'm testing your product (and Altova's) for my company. I only have one or two days to answer these questions!
I have (at least) two things I need to accomplish:
1. Most importantly, I need to take this decimal value:
123.4
and convert it to this string value
0000012340+
In other words, multiply by 100 (if possible), force two (implied) decimal places, make the total length 11 with leading zeros and a plus or minus sign on the end, depending.
In Altova, I can do all this visually. I don't need to actually write an XSLT code. Can Stylus do this visually?
2. I have two schemas defined, both with the same elemenys. I need to create an XSLT from them, such that if FIELD_A is ABSENT in the input XML instance, a default value is entered into the output XML instance.
For instance:
I have a "FROM.xml", that could contain from 1 to 3 separate elements. I want to use XSLT to map that to a new "TO.xml", which has the same elements, but must contain all 3, in the correct order. If the element isn't found in the FROM.xml instance, I need to move a hard-coded default to the the same element in TO.xml.
So I want to take this FROM.xml:
<root>
<ELEMENT_B>some real value</ELEMENT_B>
</root>
and generate this TO.xml:
<root>
<ELEMENT_A>some default value</ELEMENT_A>
<ELEMENT_B>some real value</ELEMENT_B>
<ELEMENT_C>some other default value</ELEMENT_C>
</root>
Is this possible with Stylus? If so, how?
I don't know if this matters, but I have XSD's defined for both XML's. I have tried making all the elements a sequence in the TO.xsd, but MapForce seems to ignore that.
HELP! HELP! HELP!
Thanks a lot!
--Brian
|
next
|
 Subject: Newbie: HELP! How to do simple transforms and defaults visually in Stylus ? Author: Brian McNamara Date: 26 Jan 2005 12:07 PM
|
Dear Ivan,
Thank you so much for your response to my XSLT question. That was very helpful.
Would you be able to help me with a follow-up question?
In MapForce, I would be able to visually draw an equivalent of the XSLT code you sent me, put it in it’s own box, label it, and re-use it visually. For instance, I could take something like:
<xsl:variable name="val" select="@bookid * 100"/>
<xsl:value-of select= "concat( substring('00000000000', 1, (11 - string-length($val)) ), substring($val, 1, 11))"/>
and label it “Convert_Decimal_to_Dollar_String”. I could define an “input” to the box.
Then, I could drag that box into my visual XSLT builder, and draw a line from the “FROM”, to the new box, and then to the “TO”.
Is that possible with Stylus? (Again, I’m brand new to Stylus. Maybe this is obvious…)
Thank you once again for your help.
--Brian McNamara
Sr. Software Development Manager
Focus Technology Group
(978)535-9626
|
|
|
|