Vim syntax highlighting for FAME - vim-syntax-highlighting

This is probably a shot in the dark considering how obscure the FAME programming language is, but is anyone familiar with already extant FAME syntax highlighting file for Vim?

I have made a syntax highlighting file for Notepad++.
It's not perfect, feel free to upgrade it.
<NotepadPlus>
<UserLang name="FAME" ext="pro inp" udlVersion="2.1">
<Settings>
<Global caseIgnored="yes" allowFoldOfComments="yes" foldCompact="yes" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="yes" Keywords3="yes" Keywords4="no" Keywords5="no" Keywords6="yes" Keywords7="yes" Keywords8="yes" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00-- 01 02 03/* 04*/</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
<Keywords name="Numbers, extras1"></Keywords>
<Keywords name="Numbers, extras2"></Keywords>
<Keywords name="Numbers, suffix1"></Keywords>
<Keywords name="Numbers, suffix2"></Keywords>
<Keywords name="Numbers, range"></Keywords>
<Keywords name="Operators1">&</Keywords>
<Keywords name="Operators2"></Keywords>
<Keywords name="Folders in code1, open">&apos; + ,</Keywords>
<Keywords name="Folders in code1, middle">; = , + " :</Keywords>
<Keywords name="Folders in code1, close">,</Keywords>
<Keywords name="Folders in code2, open"></Keywords>
<Keywords name="Folders in code2, middle"></Keywords>
<Keywords name="Folders in code2, close"></Keywords>
<Keywords name="Folders in comment, open">--=</Keywords>
<Keywords name="Folders in comment, middle"></Keywords>
<Keywords name="Folders in comment, close">=--</Keywords>
<Keywords name="Keywords1">BLOCK
CD
CLOSE
CREATE
DISPLAY
END
EXHIBIT
EXIT
HELP
INFO
INPUT
MESSAGE
OPEN
OUTPUT
REDO
REFILE
RESET
SETENV
SLEEP
SUBSTITUTE
SYSTEM
TYPE
UNSAVE
UNSETENV
WRITE
BLOCK
CD
CLOSE
CREATE
DISPLAY
END
EXHIBIT
EXIT
HELP
INFO
INPUT
MESSAGE
OPEN
OUTPUT
REDO
REFILE
RESET
SETENV
SLEEP
SUBSTITUTE
SYSTEM
TYPE
UNSAVE
UNSETENV
WRITE
ALIAS
ASSOCIATE
ATTRIBUTE
BASIS
CATALOG
COPY
DBSTATUS
DELETE
DESCRIPTION
DIMENSION
DOCUMENTATION
EXTRADOTS
FORMULA
GLFORMULA
GLNAME
MODIFY
NEW
OBSERVED
POST
RENAME
REOPEN
RESTORE
SCALAR
SEARCH
SERIES
SET
STRINGLENGTH
UPDATE
WHATS
WHICH
CONNECT
DISCONNECT
OPEN
EXIT
CLOSE
OPEN
RABORT
RASSERT
RATTRIBUTE
RCOMMIT
RCOPY
RDELETE
RRENAME
RSET
ADJUST
BEST
CORRELATE
EXTRAPOLATE
FIT
STEST
SUMMARIZE
APPLY
BACKTO
ENTER
ENTRY
FIELD
FORM
GHOST
INITIALIZE
LEAVE
MENU
RECALCULATE
REENTER
TERMINATE
TRIGGER
UNGHOST
VALIDATE
CLEAR
DATA
DATA PIE
DRAW ARROW
DRAW BOX
DRAW LINE
DRAW MARKING
DRAW NOTE
DRAW REGION
DRAW TEXT
GRAPH
GRAPH PIE
PICTURE
REFRESH
BLANK
FOOTING
HEADING
LINE
NEWPAGE
PRINT
REPORT
SCORE
SELECT
STROKE
TEXT
VALPRINT
ACCEPT
ARGUMENT
CANCEL
CATCH
CLOAD
COMPILE
ESCAPE
EXEC
EXECUTE
FUNCTION
IF
LOAD
LOCAL
LOOP
NEXT
PEEL
PROCEDURE
PROMPT
READ
RESIGNAL
RETURN
SIGNAL
TRY
UNLOAD
CONCEAL
HIDE
REVEAL
XYGET
ITEM
GLUE
OVER
IGNORE
IMAGE
FALSE
TRUE
DISP
OTHERWISE
ELSE
DECIMAL
channel
TRACE</Keywords>
<Keywords name="Keywords2">ANNUAL
BIMONTHLY
BIWEEKLY
BUSINESS
DAILY
HOURLY
MILLISECONDLY
MINUTELY
MONTHLY
PPY
QUARTERLY
SECONDLY
SEMIANNUAL
TENDAY
TWICEMONTHLY
WEEKLY
YPP</Keywords>
<Keywords name="Keywords3">ACCESS
ACF
AGGR
AGR
ALIAS
ALL
ALPHA
AMORT
ANNPCT
ANY
AR
ARGUMENT
ARIMA
ARMA
ASSOCIATE
AVE
BASEFREQ
BASETYPE
BASIS
BIWK
BOOLFMT
CASEORDER
CAVE
CHANNELS
CHANNELTYPE
CHR
CLASS
CMAX
CMIN
COLOR
CONNAME
CONVERT
CORR
CPROD
CREATED
CROSSLIST
CSUM
CTOT
DATEFMT
DATEOF
DATEORDER
DAY
DB
DBCREATED
DBUPDATED
DBVERSION
DESCRIPTION
DIFF
DIMCHAR
DIMENSION
DIMNUM
DOCUMENTATION
DTY
EMA
EOF
ERRORTEXT
EVAL
EXISTS
EXTRACT
EXTRADOTS
FILE
FILESPEC
FIRST
FIRSTCASE
FIRSTDATE
FIRSTVALUE
FONT
FPERIOD
FREQ
FYEAR
GETENV
GETID
GROWTH
HOUR
ID
INDENT
INDEX
INISCAN
INTERP
IRR
KIND
LARGEST
LAST
LASTCASE
LASTDATE
LASTERROR
LASTVALUE
LASTWARNING
LEFT
LENGTH
LENGTHCASE
LENGTHDATE
LIST
LMAX
LMIN
LOCATION
LOOKUP
LOWER
LTRIM
MA
MAGIC
MAKE
MAKEDATE
MAVE
MAVEC
MAX
MAXCASE
MAXDATE
MCORR
MEAN
MEDIAN
MERGE
MILLISECOND
MIN
MINCASE
MINDATE
MINUTE
MIRROR
MISSING
MMAX
MMEDIAN
MMIN
MONTH
MOVE
MSTDDEV
MSUM
MVAR
NAME
NAMELOC
NL
NORMAL
NOW
NPV
NUMBER
NUMFMT
OBSERVED
ORD
OVERLAY
PACF
PACK
PAD
PAYBACK
PCT
PENDING
PERIOD
PIXELS
POINTS
PRECFMT
PROD
REALNAME
REMEVAL
REPEAT
REPLACE
REVERSE
RIGHT
ROBLOC
ROBVAR
RTRIM
SANNPCT
SARIMA
SCAN
SCREENINFO
SCRIPT
SECOND
SELECTNAMES
SERIES
SHIFT
SHIFTMTH
SHIFTYR
SL
SLICE
SMALLEST
SORTDATA
SORTINDEX
SORTNAMES
SOURCE
SPECIAL
STDDEV
STRING
STRINGLENGTH
STUFF
SUBSTRING
SUM
SYSTEM
SYSTEMERROR
THISDAY
TIME
TODAY
TOT
TRIM
TUNE
TYPE
UNIFORM
UNIQUE
UPDATED
UPPER
VAR
WEEKDAY
WILDLIST
WILDNAMES
WINFRAMEINFO
WININFO
YEAR
YTD
YTYDIFF
YTYPCT
$</Keywords>
<Keywords name="Keywords4">ALL
AND
AUTO
BLANK
BOOLEAN
BREAK
CASE
CASEORDER
CIRCLE
COMPLETE
DASH
DATA
DATE
DATEORDER
DESCRIPTION
DIALOG
DIV
DMAX
DMIN
DOT
ELSE
EQ
EQL
ERRORTEXT
EXCEPT
FALSE
FIRSTCASE
FIRSTDATE
FRACTION
FULL
GE
GT
HORIZONTAL
IF
INFINITY
INFO
INPUT
INTERSECT
KEYBOARD
LASTCASE
LASTDATE
LASTERROR
LASTWARNING
LE
LENGTHCASE
LENGTHDATE
LOCAL
LT
MAJOR
MATCH
MAXCASE
MAXDATE
MESSAGE
MINCASE
MINDATE
MOD
N
NA
NAMELIST
NC
ND
NE
NEGINFINITY
NEL
NEWLINE
NO
NOARG
NONE
NORMAL
NOT
NOTHING
NOW
NULL
NUMERIC
OFF
ON
OR
OUTPUT
PERIODICITY
PI
PICTURE
PRECISION
PREVIOUS
PRTn
QUOTE
SCAN
SCIRCLE
SQUARE
SSQUARE
STANDARD
STARMAGICDATE
STEP
STRIANGLE
STRING
SUBSET
SYSTEMERROR
T
TERMINAL
THEN
TIME
TODAY
TOTAL
TRIANGLE
TRUE
UNIFORM
UNION
UNSPEC
VALUE
VERSION
WORK
XOR
YES
AS
TO
IN
FOR
error</Keywords>
<Keywords name="Keywords5">ACCEPT
ARGUMENT
CANCEL
CATCH
CLOAD
COMPILE
ESCAPE
EXECUTE
FUNCTION
Function Call
IF
LOAD
LOCAL
LOOP
NEXT
PEEL
PROCEDURE
Procedure Call
PROMPT
READ
RESIGNAL
RETURN
SIGNAL
TRY
UNLOAD</Keywords>
<Keywords name="Keywords6">#</Keywords>
<Keywords name="Keywords7">&&</Keywords>
<Keywords name="Keywords8">%
</Keywords>
<Keywords name="Delimiters">00" 01 02" 03( 04 05) 06{ 07 08} 09[ 10 11] 12< 13 14> 15 16 17 18 19 20 21 22 23</Keywords>
</KeywordLists>
<Styles>
<WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="COMMENTS" fgColor="008000" bgColor="F0F0F0" fontName="Source Code Pro" fontStyle="0" nesting="0" />
<WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
<WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS2" fgColor="FF8000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS3" fgColor="18B4C5" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS4" fgColor="BF4043" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS5" fgColor="5C2E2E" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS6" fgColor="0080FF" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="00FF40" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS8" fgColor="CC7700" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
<WordsStyle name="OPERATORS" fgColor="FF0000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN CODE2" fgColor="FFFF00" bgColor="FFFFFF" fontName="#FangSong" fontStyle="3" nesting="0" />
<WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS1" fgColor="0080C0" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="F3F3F3" fontName="Source Code Pro" fontStyle="0" nesting="117702655" />
<WordsStyle name="DELIMITERS3" fgColor="8000FF" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="1" nesting="0" />
<WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFC4C4" fontName="Source Code Pro" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FF8000" fontName="Source Code Pro" fontStyle="1" nesting="512" />
<WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="Source Code Pro" fontStyle="0" nesting="0" />
</Styles>
</UserLang>

Related

Visual Studio Extension with custom command and subcommands

I'm trying to create a simple Visual Studio Extension using Visual Studio 2017 that adds commands to the project context menu in the Solution Explorer. I'd like to add my commands grouped together in a main option and then from that main option I would like my commands to be accessible, just like how the Add->New item, Add->Existing item, Add->Class etc. works for in the context menu of the project.
After going through the documentation here's what I have come up with so far for my vsct file:
<Commands package="guidMainItemPackage">
<Groups>
<Group guid="guidMainItemPackageCmdSet" id="MyMenuGroup" priority="0x0600" />
<Group guid="guidMainItemPackageCmdSet" id="SubMenuGroup" priority="0x0601" />
</Groups>
<Buttons>
<Button guid="guidMainItemPackageCmdSet" id="MainItemId" priority="0x0100" type="Button">
<Parent guid="guidMainItemPackageCmdSet" id="MyMenuGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Invoke MainItem</ButtonText>
</Strings>
</Button>
<Button guid="guidMainItemPackageCmdSet" id="cmdidSubItem" priority="0x0101" type="Button">
<Parent guid="guidMainItemPackageCmdSet" id="SubMenuGroup" />
<Icon guid="guidImages1" id="bmpPic1" />
<Strings>
<ButtonText>Invoke SubItem</ButtonText>
</Strings>
</Button>
</Buttons>
<Bitmaps>
<Bitmap guid="guidImages" href="Resources\MainItem.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough" />
<Bitmap guid="guidImages1" href="Resources\SubItem.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough" />
</Bitmaps>
</Commands>
<CommandPlacements>
<CommandPlacement guid="guidMainItemPackageCmdSet" id="MyMenuGroup" priority="0xFFFF">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE" />
</CommandPlacement>
<CommandPlacement guid="guidMainItemPackageCmdSet" id="SubMenuGroup" priority="0xFFFE">
<Parent guid="guidMainItemPackageCmdSet" id="MyMenuGroup" />
</CommandPlacement>
</CommandPlacements>
<Symbols>
<GuidSymbol name="guidMainItemPackage" value="{30f66380-eeeb-48bf-8554-0d63d87194af}" />
<GuidSymbol name="guidMainItemPackageCmdSet" value="{98ee7e8f-c421-4f0e-a9e9-86eab5141563}">
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="SubMenuGroup" value="0x1028" />
<IDSymbol name="MainItemId" value="0x0100" />
<IDSymbol value="4129" name="cmdidSubItem" />
</GuidSymbol>
<GuidSymbol name="guidImages" value="{b3c2dfad-df35-4e6b-880e-8018ce6c3d0f}">
<IDSymbol name="bmpPic1" value="1" />
<IDSymbol name="bmpPic2" value="2" />
<IDSymbol name="bmpPicSearch" value="3" />
<IDSymbol name="bmpPicX" value="4" />
<IDSymbol name="bmpPicArrows" value="5" />
<IDSymbol name="bmpPicStrikethrough" value="6" />
</GuidSymbol>
<GuidSymbol value="{93d3ad22-fe33-40da-b85f-a926952e3914}" name="guidImages1">
<IDSymbol name="bmpPic1" value="1" />
<IDSymbol name="bmpPic2" value="2" />
<IDSymbol name="bmpPicSearch" value="3" />
<IDSymbol name="bmpPicX" value="4" />
<IDSymbol name="bmpPicArrows" value="5" />
<IDSymbol name="bmpPicStrikethrough" value="6" />
</GuidSymbol>
</Symbols>
So basically I have created added two Custom commands to my project, a button for each of the commands, a group for each of the buttons and a commandplacement for each of the groups (everything else is just the default generated vsct template).
My problem is that using the code above, on the first command is displayed and it has no subitems. What would be the correct vsct content to achieve the desired layout?
After some more trial and error (mostly error), I decided to go through the command definitions of Visual Studio itself to find a similar group of commands, and I've finally came up with the answer. Here's the steps you need to take to realize this structure:
Create a group and set the parent of this group to the Visual Studio projects context menu.
Create a menu, whose parent is the group created in step 1.
Create a second group, whose parent is the menu created in step 2.
Create buttons for only the subitems.
Create commandplacements for the subitems created in step 4 where you place each button in the group created in step 3.

Spring webflow Value of second parameter is not passed to subflow

Hi, I am using spring webflow2.4.4 with spring4.1.3.
I am trying to pass values between two flows as below.
sending value from flow first xml
<action-state id="submit">
<evaluate expression="someMethod(form)" result="flowScope.saveStatus" />
<set name="flowScope.value1" value="form.value1" />
<set name="flowScope.value2" value="form.value2" />
<transition on="success" to="view" />
</action-state>
<subflow-state id="view" subflow="flow/path/view">
<input name="value1" value="value1" />
<input name="value2" value="value2" />
...
</subflow-state>
reeving data in flow second view xml
<input name="value1" type="string" />
<input name="value2" type="string" />
now in view xml I am able to receive value for "value1" what I passed from first flow but getting value for 'value2' is null.
I tried switching the position in first flow as below
<action-state id="submit">
<evaluate expression="someMethod(form)" result="flowScope.saveStatus" />
<set name="flowScope.value2" value="form.value2" />
<set name="flowScope.value1" value="form.value1" />
<transition on="success" to="view" />
</action-state>
<subflow-state id="view" subflow="flow/path/view">
<input name="value2" value="value2" />
<input name="value1" value="value1" />
...
</subflow-state>
Now I am able to see value of 'value2' but value for 'value1' receiving is null.
What is wrong here? see below debug logs for both example
1st trial
DEBUG SubflowState - Calling subflow 'flow/path/view' with input map['value1' -> 'ABCDF', 'value2' -> [null]]
2nd trial
DEBUG SubflowState - Calling subflow 'flow/path/view' with input map['value2' -> 'ABCDF', 'value1' -> [null]]
I want to pass both thew values to second flow but it second parameter is getting skipped somehow.
this is a very common mistake. the action state is transitioning when it gets a success and stops evaluating the rest of the commands.
you need to use <on-entry> to separate the two:
the commands you want to set or evaluate (value1 & value2)
the command that will be evaluated for the transition, here someMethod(form))
use this instead:
<action-state id="submit">
<on-entry>
<set name="flowScope.value2" value="form.value2" />
<set name="flowScope.value1" value="form.value1" />
</on-entry>
<evaluate expression="someMethod(form)" result="flowScope.saveStatus" />
<transition on="success" to="view" />
</action-state>
Thanks rptmat57, below code worked for me.
<action-state id="submit">
<evaluate expression="someMethod(form)" result="flowScope.saveStatus" />
<transition on="success" to="view" >
<set name="flowScope.value2" value="form.value2" />
<set name="flowScope.value1" value="form.value1" />
</transition>
</action-state>

BizTalk - mapping a source that has a Parent-Child relationship a flat destination

I have seen this question about a parent child relationship, but it is not exactly the same since I have nothing to tag with.
I have a source flat file that look like this
Location Route Prod Company Date Amount
XXX RT00008 UT COMPANY1 20110926 3
XXX RT00008 UT COMPANY1 20110927 1
XXX RT00008 UT COMPANY1 20110928 1
XXX RT00008 UT COMPANY1 20110929 1
XXX RT00008 UT COMPANY1 20110930 1
XXX RT00171 SPW COMPANY2 20110928 1
XXX RT00171 UT COMPANY2 20110926 1
XXX RT00171 UT COMPANY2 20110927 1
XXX RT00171 UT COMPANY2 20110928 1
Here is the killer, for each unique combination of Route, Prod, and Company I need one record with the days of week filled in. For instance the previous example should map into 3 separate rows in the output.
Loc, Route, Pr, Company, Sun, Mon, Tues, Wed, Thur, Fri, Sat
XXX, RT00008, UT, COMPANY1, 0, 3, 1, 1, 1, 1, 1
XXX, RT00171, SPW, COMPANY2, 0, 0, 0, 1, 0, 0, 0
XXX, RT00171, UT, COMPANY2, 0, 1, 1, 1, 0, 0, 0
Now my question is, is there a way to do this without XSLT? Can it be done by using functoid, in one or more series of maps? It seems like the table looping functoid is custom built for the opposite of this situation, can it be done in reverse? If it can only be done using XSLT I am still scratching my head on how to do it?
Thanks for any help!
I created two schema representations of your Flat files (not flat file schemas, but they will suffice for the illustration).
I started with a biztalk map thats would populate the first day with the appropriate value for a given combo of Company, Route and Prod. I went to xsl to allow it loop through a collection of identified combos to populate ALL days for the identified combo.
Its probably best that you load up the .btm supplied along with the schemas and xsl to see what I've done. I can explain anything thats unclear.
Its probably worth noting that you could tidy up the solution but I hope it gives you a pointer.
Two points to note: the "day" nodes are only created when a value exists for that day. You can change this in the xsl.
And, I used a valid date time to test (e.g. 26-09-2011) so you'll have to parse your date when determining what DayOfWeek your date is.
The first Schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://BizTalk_Server_Project2.Schema1" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalk_Server_Project2.Schema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="Record">
<xs:complexType>
<xs:sequence>
<xs:element name="Location" type="xs:string" />
<xs:element name="Route" type="xs:string" />
<xs:element name="Prod" type="xs:string" />
<xs:element name="Company" type="xs:string" />
<xs:element name="Date" type="xs:string" />
<xs:element name="Amount" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The second schema:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://BizTalk_Server_Project2.Schema2" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalk_Server_Project2.Schema2" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="unbounded" name="Record">
<xs:complexType>
<xs:sequence>
<xs:element name="Loc" type="xs:string" />
<xs:element name="Route" type="xs:string" />
<xs:element name="Pr" type="xs:string" />
<xs:element name="Company" type="xs:string" />
<xs:element name="Sun" type="xs:string" />
<xs:element name="Mon" type="xs:string" />
<xs:element name="Tue" type="xs:string" />
<xs:element name="Wed" type="xs:string" />
<xs:element name="Thurs" type="xs:string" />
<xs:element name="Friday" type="xs:string" />
<xs:element name="Sat" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The BizTalk Map:
<?xml version="1.0" encoding="utf-16"?>
<mapsource Name="BizTalk Map" Version="2" BizTalkServerMapperTool_Version="3.0" XRange="100" YRange="420" OmitXmlDeclaration="Yes" TreatElementsAsRecords="No" OptimizeValueMapping="Yes" GenerateDefaultFixedNodes="Yes" PreserveSequenceOrder="No" IgnoreNamespacesForLinks="Yes" method="xml" CopyPIs="No" xmlVersion="1.0">
<SrcTree RootNode_Name="Root">
<Reference Location=".\Schema1.xsd" />
</SrcTree>
<TrgTree RootNode_Name="Root">
<Reference Location=".\Schema2.xsd" />
</TrgTree>
<ScriptTypePrecedence>
<CSharp Enabled="Yes" />
<ExternalAssembly Enabled="Yes" />
<VbNet Enabled="Yes" />
<JScript Enabled="Yes" />
<XsltCallTemplate Enabled="Yes" />
<Xslt Enabled="Yes" />
</ScriptTypePrecedence>
<TreeValues>
<TestValues />
<ConstantValues />
</TreeValues>
<CustomXSLT XsltPath=".\Map1.xsl" ExtObjXmlPath=".\Map1_extxml.xml" />
<Pages>
<Page Name="Page 1">
<Links>
<Link LinkID="22" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Date']" LinkTo="107" />
<Link LinkID="19" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Company']" LinkTo="106" />
<Link LinkID="16" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Prod']" LinkTo="105" />
<Link LinkID="14" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Route']" LinkTo="104" />
<Link LinkID="20" LinkFrom="106" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Company']" />
<Link LinkID="15" LinkFrom="104" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Route']" />
<Link LinkID="11" LinkFrom="103" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Loc']" />
<Link LinkID="10" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Location']" LinkTo="103" />
<Link LinkID="18" LinkFrom="102" LinkTo="106" />
<Link LinkID="13" LinkFrom="102" LinkTo="105" />
<Link LinkID="12" LinkFrom="102" LinkTo="104" />
<Link LinkID="9" LinkFrom="102" LinkTo="103" />
<Link LinkID="1" LinkFrom="98" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']" />
<Link LinkID="8" LinkFrom="101" LinkTo="102" />
<Link LinkID="6" LinkFrom="99" LinkTo="101" />
<Link LinkID="21" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Company']" LinkTo="100" />
<Link LinkID="3" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Route']" LinkTo="100" />
<Link LinkID="4" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Prod']" LinkTo="100" />
<Link LinkID="5" LinkFrom="100" LinkTo="99" />
<Link LinkID="24" LinkFrom="107" LinkTo="109" />
<Link LinkID="31" LinkFrom="109" LinkTo="117" />
<Link LinkID="38" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Amount']" LinkTo="117" />
<Link LinkID="30" LinkFrom="108" LinkTo="116" />
<Link LinkID="23" LinkFrom="107" LinkTo="108" />
<Link LinkID="37" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Amount']" LinkTo="116" />
<Link LinkID="33" LinkFrom="110" LinkTo="119" />
<Link LinkID="32" LinkFrom="112" LinkTo="118" />
<Link LinkID="34" LinkFrom="113" LinkTo="120" />
<Link LinkID="35" LinkFrom="114" LinkTo="121" />
<Link LinkID="36" LinkFrom="115" LinkTo="122" />
<Link LinkID="26" LinkFrom="107" LinkTo="110" />
<Link LinkID="25" LinkFrom="107" LinkTo="112" />
<Link LinkID="27" LinkFrom="107" LinkTo="113" />
<Link LinkID="28" LinkFrom="107" LinkTo="114" />
<Link LinkID="29" LinkFrom="107" LinkTo="115" />
<Link LinkID="39" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Amount']" LinkTo="118" />
<Link LinkID="40" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Amount']" LinkTo="119" />
<Link LinkID="41" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Amount']" LinkTo="120" />
<Link LinkID="42" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Amount']" LinkTo="121" />
<Link LinkID="43" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Amount']" LinkTo="122" />
<Link LinkID="17" LinkFrom="105" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Pr']" />
<Link LinkID="44" LinkFrom="116" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Sun']" />
<Link LinkID="45" LinkFrom="117" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Mon']" />
<Link LinkID="46" LinkFrom="118" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Tue']" />
<Link LinkID="47" LinkFrom="119" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Wed']" />
<Link LinkID="48" LinkFrom="120" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Thurs']" />
<Link LinkID="49" LinkFrom="121" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Friday']" />
<Link LinkID="50" LinkFrom="122" LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/*[local-name()='Sat']" />
</Links>
<Functoids>
<Functoid FunctoidID="107" Functoid-FID="260" X-Cell="52" Y-Cell="194">
<Input-Parameters>
<Parameter Type="link" Value="22" linkIndex="0" Guid="7470c0bc-c75c-4ab5-99f2-250d7fe1e389" />
</Input-Parameters>
<ScripterCode>
<Script Language="CSharp">
<![CDATA[///*Uncomment the following code for a sample Inline C# function
//that concatenates two inputs. Change the number of parameters of
//this function to be equal to the number of inputs connected to this functoid.*/
public string dow(string myDate)
{
return DateTime.Parse(myDate).DayOfWeek.ToString();
}
]]>
</Script>
</ScripterCode>
</Functoid>
<Functoid FunctoidID="106" Functoid-FID="375" X-Cell="56" Y-Cell="193">
<Input-Parameters>
<Parameter Type="link" Value="18" linkIndex="0" Guid="87396644-e663-4615-9e42-67060259fb1a" />
<Parameter Type="link" Value="19" linkIndex="1" Guid="cc39c66f-59fd-427d-aefc-5c1195e6a72f" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="105" Functoid-FID="375" X-Cell="56" Y-Cell="191">
<Input-Parameters>
<Parameter Type="link" Value="13" linkIndex="0" Guid="691fde94-db0b-4f53-b2ee-ff8f8f980027" />
<Parameter Type="link" Value="16" linkIndex="1" Guid="04844567-8d00-44cd-9b90-89e5009c4269" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="104" Functoid-FID="375" X-Cell="56" Y-Cell="189">
<Input-Parameters>
<Parameter Type="link" Value="12" linkIndex="0" Guid="16e52083-f9c4-4563-980c-146f4621dab6" />
<Parameter Type="link" Value="14" linkIndex="1" Guid="58d9d487-43be-4e7a-a0b0-efbbae08d004" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="103" Functoid-FID="375" X-Cell="56" Y-Cell="187">
<Input-Parameters>
<Parameter Type="link" Value="9" linkIndex="0" Guid="230f2ff4-b9aa-4903-893b-90bd3fe49540" />
<Parameter Type="link" Value="10" linkIndex="1" Guid="5cc1c29a-7398-4005-ace7-4cbc4c176960" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="102" Functoid-FID="705" X-Cell="54" Y-Cell="186">
<Input-Parameters>
<Parameter Type="link" Value="8" linkIndex="0" Guid="b3777b48-0d39-499c-96c9-40ffdd0c8737" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="98" Functoid-FID="260" X-Cell="52" Y-Cell="182">
<Input-Parameters />
<ScripterCode>
<Script Language="CSharp">
<![CDATA[// declare global variables for Voucher number assignment
System.Collections.Generic.List<string> keyList =
new System.Collections.Generic.List<string>();
public void init(){}
]]>
</Script>
</ScripterCode>
</Functoid>
<Functoid FunctoidID="101" Functoid-FID="315" X-Cell="54" Y-Cell="184">
<Input-Parameters>
<Parameter Type="link" Value="6" linkIndex="0" Guid="4a5c621f-9f4f-4b1f-a81b-6dce03aa402a" />
<Parameter Type="constant" Value="true" linkIndex="1" Guid="5aafc712-0e6c-44be-baf8-c3a7d8806eb5" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="99" Functoid-FID="260" X-Cell="52" Y-Cell="184">
<Input-Parameters>
<Parameter Type="link" Value="5" linkIndex="0" Guid="bb64de45-0250-4d51-8ee3-4759d7812160" />
</Input-Parameters>
<ScripterCode>
<Script Language="CSharp">
<![CDATA[// Add invoice number to list if it doesn't already exist.
// increment voucher number if new invoice
public Boolean AddKeyToList(string key)
{
// if the Invoice number is not already in the List
if (!keyList.Contains(key))
{
// Add to list
keyList.Add(key);
return true;
}
return false;
}]]>
</Script>
</ScripterCode>
</Functoid>
<Functoid FunctoidID="100" Functoid-FID="107" X-Cell="44" Y-Cell="175">
<Input-Parameters>
<Parameter Type="link" Value="21" linkIndex="0" Guid="f630c6c2-b5c2-4c77-bf53-d25fdfb06b78" />
<Parameter Type="link" Value="3" linkIndex="1" Guid="f24d57bc-22d9-4390-bdf1-52ca16f9b45b" />
<Parameter Type="link" Value="4" linkIndex="2" Guid="87ee7e4f-374c-4343-aa68-0a5bf6fffac7" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="117" Functoid-FID="375" X-Cell="56" Y-Cell="195">
<Input-Parameters>
<Parameter Type="link" Value="31" linkIndex="0" Guid="4e5e0ad8-543e-4a41-b702-74d2d8356030" />
<Parameter Type="link" Value="38" linkIndex="1" Guid="c94e83a7-1220-4797-ac03-751e089e9a07" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="109" Functoid-FID="315" X-Cell="54" Y-Cell="195">
<Input-Parameters>
<Parameter Type="link" Value="24" linkIndex="0" Guid="c6998772-def3-4a8a-ae7d-0cdb947f95a4" />
<Parameter Type="constant" Value="Monday" linkIndex="1" Guid="64603dba-6df1-4b59-8968-62949ccc6759" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="108" Functoid-FID="315" X-Cell="54" Y-Cell="194">
<Input-Parameters>
<Parameter Type="link" Value="23" linkIndex="0" Guid="d44d97ba-b3d3-48cd-a3c9-7ce4726d35df" />
<Parameter Type="constant" Value="Sunday" linkIndex="1" Guid="75cf8619-0493-4aac-9f76-1a020d7fac0f" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="116" Functoid-FID="375" X-Cell="56" Y-Cell="194">
<Input-Parameters>
<Parameter Type="link" Value="30" linkIndex="0" Guid="c37bfe5c-9a5a-4b23-b300-16c942ba785b" />
<Parameter Type="link" Value="37" linkIndex="1" Guid="b02aab3d-6437-401c-9b06-bdf7c7d9c832" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="110" Functoid-FID="315" X-Cell="54" Y-Cell="197">
<Input-Parameters>
<Parameter Type="link" Value="26" linkIndex="0" Guid="1cd88b45-1667-416e-aeef-78cc599f3cc7" />
<Parameter Type="constant" Value="Wednesday" linkIndex="1" Guid="773c8e04-45a2-4d1e-983f-0b53745c038f" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="112" Functoid-FID="315" X-Cell="54" Y-Cell="196">
<Input-Parameters>
<Parameter Type="link" Value="25" linkIndex="0" Guid="599dfe5a-202b-49ee-a439-1276296501bd" />
<Parameter Type="constant" Value="Tuesday" linkIndex="1" Guid="bd4a7be3-b886-4cad-ab71-077b9cb507e0" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="113" Functoid-FID="315" X-Cell="54" Y-Cell="198">
<Input-Parameters>
<Parameter Type="link" Value="27" linkIndex="0" Guid="61d375df-85ad-49ef-8161-5c7908e7a1f9" />
<Parameter Type="constant" Value="Thursday" linkIndex="1" Guid="efb2d4af-52e1-41c3-8886-e8acbcf6f788" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="114" Functoid-FID="315" X-Cell="54" Y-Cell="199">
<Input-Parameters>
<Parameter Type="link" Value="28" linkIndex="0" Guid="84dc8167-ef26-41e2-8cbc-92bc09d9b513" />
<Parameter Type="constant" Value="Friday" linkIndex="1" Guid="bdea9f04-4e4d-458a-bc6c-5a7d063a9128" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="115" Functoid-FID="315" X-Cell="54" Y-Cell="200">
<Input-Parameters>
<Parameter Type="link" Value="29" linkIndex="0" Guid="ad77c87e-b292-4b10-9932-7fc9f5981869" />
<Parameter Type="constant" Value="Saturday" linkIndex="1" Guid="d811f065-8eed-4445-9356-fe5327b2c634" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="118" Functoid-FID="375" X-Cell="56" Y-Cell="196">
<Input-Parameters>
<Parameter Type="link" Value="32" linkIndex="0" Guid="32cd8143-b582-4d49-a048-84e54cd42bea" />
<Parameter Type="link" Value="39" linkIndex="1" Guid="95fffee4-6451-442d-9a60-19a297388aa5" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="119" Functoid-FID="375" X-Cell="56" Y-Cell="197">
<Input-Parameters>
<Parameter Type="link" Value="33" linkIndex="0" Guid="d222802d-a84e-4cdd-8920-48623705506d" />
<Parameter Type="link" Value="40" linkIndex="1" Guid="9be3005a-d0e2-454d-b970-a350becadf5d" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="120" Functoid-FID="375" X-Cell="56" Y-Cell="198">
<Input-Parameters>
<Parameter Type="link" Value="34" linkIndex="0" Guid="bfe3b4b6-c52a-4762-9c2c-b868d7f203fd" />
<Parameter Type="link" Value="41" linkIndex="1" Guid="f7eed5ef-5156-4d4b-8cc9-42a5c5773ec2" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="121" Functoid-FID="375" X-Cell="56" Y-Cell="199">
<Input-Parameters>
<Parameter Type="link" Value="35" linkIndex="0" Guid="d2765ea5-a23c-43f5-834e-ec5e610f1114" />
<Parameter Type="link" Value="42" linkIndex="1" Guid="ccf811b9-31bc-4cb2-9d00-fa784c357575" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="122" Functoid-FID="375" X-Cell="56" Y-Cell="200">
<Input-Parameters>
<Parameter Type="link" Value="36" linkIndex="0" Guid="63f4d89b-0487-434a-97a7-137b70376867" />
<Parameter Type="link" Value="43" linkIndex="1" Guid="2f302981-121d-4825-8251-6b9bd0123278" />
</Input-Parameters>
</Functoid>
</Functoids>
</Page>
</Pages>
</mapsource>
in the generated xsl, replace the <Root> element with:
<ns0:Root>
<xsl:for-each select="Record">
<xsl:variable name="var:v1" select="userCSharp:StringConcat(string(Company/text()) , string(Route/text()) , string(Prod/text()))" />
<xsl:variable name="var:v6" select="string(Company/text())" />
<xsl:variable name="var:v7" select="string(Route/text())" />
<xsl:variable name="var:v8" select="string(Prod/text())" />
<xsl:variable name="var:v9" select="userCSharp:StringConcat($var:v6 , $var:v7 , $var:v8)" />
<xsl:variable name="var:v25" select="string(Date/text())" />
<!-- Only create a new record node in the destibation if the Keys are different! -->
<xsl:variable name="varCurrentCompany" select="string(Company/text())" />
<xsl:variable name="varPrevCompany" select="string(preceding-sibling::Record[1]/Company/text())" />
<xsl:variable name="varCurrentRoute" select="string(Route/text())" />
<xsl:variable name="varPrevRoute" select="string(preceding-sibling::Record[1]/Route/text())" />
<xsl:variable name="varCurrentProd" select="string(Prod/text())" />
<xsl:variable name="varPrevProd" select="string(preceding-sibling::Record[1]/Prod/text())" />
<!-- do this by checking if the current record is different to the previous record -->
<xsl:if test="($varCurrentCompany!=$varPrevCompany) or ($varCurrentRoute!=$varPrevRoute) or ($varCurrentProd!=$varPrevProd)">
<Record>
<xsl:variable name="var:v2" select="userCSharp:AddKeyToList(string($var:v1))" />
<xsl:variable name="var:v3" select="userCSharp:LogicalEq(string($var:v2) , "true")" />
<xsl:variable name="var:v4" select="userCSharp:LogicalNot(string($var:v3))" />
<xsl:if test="string($var:v4)='true'">
<xsl:variable name="var:v5" select="Location/text()" />
<Loc>
<xsl:value-of select="$var:v5" />
</Loc>
</xsl:if>
<xsl:variable name="var:v10" select="userCSharp:AddKeyToList(string($var:v9))" />
<xsl:variable name="var:v11" select="userCSharp:LogicalEq(string($var:v10) , "true")" />
<xsl:variable name="var:v12" select="userCSharp:LogicalNot(string($var:v11))" />
<xsl:if test="string($var:v12)='true'">
<xsl:variable name="var:v13" select="Route/text()" />
<Route>
<xsl:value-of select="$var:v13" />
</Route>
</xsl:if>
<xsl:variable name="var:v14" select="userCSharp:AddKeyToList(string($var:v9))" />
<xsl:variable name="var:v15" select="userCSharp:LogicalEq(string($var:v14) , "true")" />
<xsl:variable name="var:v16" select="userCSharp:LogicalNot(string($var:v15))" />
<xsl:if test="string($var:v16)='true'">
<xsl:variable name="var:v17" select="Prod/text()" />
<Pr>
<xsl:value-of select="$var:v17" />
</Pr>
</xsl:if>
<xsl:variable name="var:v18" select="userCSharp:AddKeyToList(string($var:v9))" />
<xsl:variable name="var:v19" select="userCSharp:LogicalEq(string($var:v18) , "true")" />
<xsl:variable name="var:v20" select="userCSharp:LogicalNot(string($var:v19))" />
<xsl:if test="string($var:v20)='true'">
<xsl:variable name="var:v21" select="Company/text()" />
<Company>
<xsl:value-of select="$var:v21" />
</Company>
</xsl:if>
</Record>
</xsl:if>
<xsl:variable name="var:v22" select="userCSharp:dow(string(Date/text()))" />
<xsl:variable name="var:v23" select="userCSharp:LogicalEq(string($var:v22) , "Sunday")" />
<xsl:if test="string($var:v23)='true'">
<xsl:variable name="var:v24" select="Amount/text()" />
<Sun>
<xsl:value-of select="$var:v24" />
</Sun>
</xsl:if>
<xsl:variable name="var:v26" select="userCSharp:dow($var:v25)" />
<xsl:variable name="var:v27" select="userCSharp:LogicalEq(string($var:v26) , "Monday")" />
<xsl:if test="string($var:v27)='true'">
<xsl:variable name="var:v28" select="Amount/text()" />
<Mon>
<xsl:value-of select="$var:v28" />
</Mon>
</xsl:if>
<xsl:variable name="var:v29" select="userCSharp:dow($var:v25)" />
<xsl:variable name="var:v30" select="userCSharp:LogicalEq(string($var:v29) , "Tuesday")" />
<xsl:if test="string($var:v30)='true'">
<xsl:variable name="var:v31" select="Amount/text()" />
<Tue>
<xsl:value-of select="$var:v31" />
</Tue>
</xsl:if>
<xsl:variable name="var:v32" select="userCSharp:dow($var:v25)" />
<xsl:variable name="var:v33" select="userCSharp:LogicalEq(string($var:v32) , "Wednesday")" />
<xsl:if test="string($var:v33)='true'">
<xsl:variable name="var:v34" select="Amount/text()" />
<Wed>
<xsl:value-of select="$var:v34" />
</Wed>
</xsl:if>
<xsl:variable name="var:v35" select="userCSharp:dow($var:v25)" />
<xsl:variable name="var:v36" select="userCSharp:LogicalEq(string($var:v35) , "Thursday")" />
<xsl:if test="string($var:v36)='true'">
<xsl:variable name="var:v37" select="Amount/text()" />
<Thurs>
<xsl:value-of select="$var:v37" />
</Thurs>
</xsl:if>
<xsl:variable name="var:v38" select="userCSharp:dow($var:v25)" />
<xsl:variable name="var:v39" select="userCSharp:LogicalEq(string($var:v38) , "Friday")" />
<xsl:if test="string($var:v39)='true'">
<xsl:variable name="var:v40" select="Amount/text()" />
<Friday>
<xsl:value-of select="$var:v40" />
</Friday>
</xsl:if>
<xsl:variable name="var:v41" select="userCSharp:dow($var:v25)" />
<xsl:variable name="var:v42" select="userCSharp:LogicalEq(string($var:v41) , "Saturday")" />
<xsl:if test="string($var:v42)='true'">
<xsl:variable name="var:v43" select="Amount/text()" />
<Sat>
<xsl:value-of select="$var:v43" />
</Sat>
</xsl:if>
</xsl:for-each>
<xsl:variable name="var:v44" select="userCSharp:init()" />
<xsl:value-of select="$var:v44" />
</ns0:Root>

Flex 4 Changing style options with states

I'm interested in finding out the best approach to this issue, it's not technically difficult but there must be an elegant solution.
Basically i have a form that features mostly text inputs, i would like to change the style of the input boxes based on the current state.
I can do this in the mxml on each input...
<s:TextInput text="label" borderColor.State1="0xFFFFFF" borderColor.State2="0x000000"/>
But that involves creating properties on every single item in the form.
There must be a better way of doing this without adding a property to each item?
Thanks!
You can use transitions and SetAction to set styles on multiple objects at the same time based on a new viewstate. This is a piece of an example from the SDK documentation:
.
<s:states>
<s:State name="Login" />
<s:State name="Register" />
</s:states>
<s:transitions>
<!-- Define the transition from the base state to the Register state.-->
<s:Transition id="toRegister" fromState="*" toState="Register">
<s:Sequence targets="{[loginPanel, registerLink, confirm, loginLink]}">
<s:RemoveAction />
<s:Fade />
<s:SetAction target="{loginPanel}" property="title" />
<s:SetAction target="{loginButton}" property="label" />
<s:SetAction target="{loginButton}" property="color" />
<s:Resize target="{loginPanel}"/>
<s:AddAction />
<s:Fade />
</s:Sequence>
</s:Transition>
<!-- Define the transition from the Register state to the base state.-->
<s:Transition id="toDefault" fromState="Register" toState="*">
<s:Sequence targets="{[loginPanel, registerLink,
confirm, loginLink]}">
<s:RemoveAction/>
<s:SetAction target="{loginPanel}" property="title"/>
<s:SetAction target="{loginButton}" property="label"/>
<s:SetAction target="{loginButton}" property="color"/>
<s:Resize target="{loginPanel}"/>
<s:AddAction/>
</s:Sequence>
</s:Transition>
</s:transitions>
You can just target everything in the sequence (instead using different targets for each SetAction) and use the 'value' property of the SetAction to set the values to what you want.

What is the best practice for changing view states?

I have a component with two Pie Charts that display percentages at two specific dates (think start and end values). But, I have three views: Start Value only, End Value only, or show Both. I am using a ToggleButtonBar to control the display. What is the best practice for changing this kind of view state? Right now (since this code was inherited), the view states are changed in an ActionScript function which sets the visible and includeInLayout properties on each Pie Chart based on the selectedIndex of the ToggleButtonBar, but, this just doesn't seem like the best way to do this - not very dynamic. I'd like to be able to change the state based on the name of the selectedItem, in case the order of the ToggleButtons changes, and since I am storing the name of the selectedItem for future reference.
Would using States be better? If so, what would be the best way to implement this?
Thanks.
Current logic:
private function pieTypeToggleButtonBar_itemClickHandler():void
{
// Show/Hide the appropriate Pie Charts based on the user's selection
switch (pieTypeToggleButtonBar.selectedIndex)
{
// "Start Value" is selected
case 0:
{
// Hide the End Value Pie Chart
endValuePieChartVBox.visible = false;
endValuePieChartVBox.includeInLayout = false;
// Show the Start Value Pie Chart
startValuePieChartVBox.includeInLayout = true;
startValuePieChartVBox.visible = true;
break;
}
// "End Value" is selected
case 1:
{
// Hide the Start Value Pie Chart
startValuePieChartVBox.visible = false;
startValuePieChartVBox.includeInLayout = false;
// Show the End Value Pie Chart
endValuePieChartVBox.includeInLayout = true;
endValuePieChartVBox.visible = true;
break;
}
// "Both" is selected
case 2:
{
// Show the Start Value Pie Chart
startValuePieChartVBox.includeInLayout = true;
startValuePieChartVBox.visible = true;
// Show the End Value Pie Chart
endValuePieChartVBox.includeInLayout = true;
endValuePieChartVBox.visible = true;
break;
}
}
}
<mx:ToggleButtonBar id="pieTypeToggleButtonBar" selectedIndex="1"
itemClick="pieTypeToggleButtonBar_itemClickHandler()">
<mx:Array>
<mx:Object name="startValue" label="Start Value" />
<mx:Object name="endValue" label="End Value" />
<mx:Object name="both" label="Both" />
</mx:Array>
</mx:ToggleButtonBar>
Since the currentState property takes a String, which maps to the name property of a state, then it sounds like using <mx:states> would work well in your case. In fact I use states often for toggling between views in just the way you describe -- setting visible and includeInLayout properties of components (usually Canvas components, or other sorts of containers) with SetProperty:
<mx:states>
<mx:State name="View State 1">
<mx:SetProperty target="{component1}" name="visible" value="true" />
<mx:SetProperty target="{component2}" name="visible" value="false" />
<mx:SetProperty target="{component3}" name="visible" value="false" />
<mx:SetProperty target="{component1}" name="includeInLayout" value="true" />
<mx:SetProperty target="{component2}" name="includeInLayout" value="false" />
<mx:SetProperty target="{component3}" name="includeInLayout" value="false" />
</mx:State>
<mx:State name="View State 2">
<mx:SetProperty target="{component1}" name="visible" value="false" />
<mx:SetProperty target="{component2}" name="visible" value="true" />
<mx:SetProperty target="{component3}" name="visible" value="false" />
<mx:SetProperty target="{component1}" name="includeInLayout" value="false" />
<mx:SetProperty target="{component2}" name="includeInLayout" value="true" />
<mx:SetProperty target="{component3}" name="includeInLayout" value="false" />
</mx:State>
<mx:State name="View State 3">
<mx:SetProperty target="{component1}" name="visible" value="false" />
<mx:SetProperty target="{component2}" name="visible" value="false" />
<mx:SetProperty target="{component3}" name="visible" value="true" />
<mx:SetProperty target="{component1}" name="includeInLayout" value="false" />
<mx:SetProperty target="{component2}" name="includeInLayout" value="false" />
<mx:SetProperty target="{component3}" name="includeInLayout" value="true" />
</mx:State>
</mx:states>
<mx:Script>
<![CDATA[
import mx.binding.utils.BindingUtils;
import mx.binding.utils.ChangeWatcher;
private function this_creationComplete(event:Event):void
{
// Use BindingUtils.bindSetter to hook into selectedIndex-change events
var cw:ChangeWatcher = BindingUtils.bindSetter(setState, myBar, "selectedIndex");
}
private function setState(index:int):void
{
currentState = myBar.getChildren()[index].label;
}
]]>
</mx:Script>
<mx:ToggleButtonBar id="myBar">
<mx:dataProvider>
<mx:Array>
<mx:String>View State 1</mx:String>
<mx:String>View State 2</mx:String>
<mx:String>View State 3</mx:String>
</mx:Array>
</mx:dataProvider>
</mx:ToggleButtonBar>
<mx:Canvas id="component1">
<mx:Text text="Component 1" />
</mx:Canvas>
<mx:Canvas id="component2">
<mx:Text text="Component 2" />
</mx:Canvas>
<mx:Canvas id="component3">
<mx:Text text="Component 3" />
</mx:Canvas>
... following this general pattern. Hope it helps!
The simplest way to do this would be to use the ViewStack component. That way you just select the selectedIndex and all the other panels will hide (watch out for initialization problems with ViewStacks).
Because of the problems i have had with ViewStacks in the past i would probably be inclined to use view states though as an alternative. States have their own problems but they are definitely feasible for this particular problem.
If i were you i would look into either of these options as a solution as the functionality created about has already been created with a standard api.... try and stick to using mx components if they fit your specific needs rather than reinventing the wheel all the time
The use of states in the first component completely misses the point. You shouldn't be setting visible and includeInLayout, you should be ADDING and REMOVING the components using AddChild and RemoveChild. The use of visible and includeInLayout to control object's state on the screen is a bastardization of their intent. Unfortunately, since Flex doesn't have any sort of conditional logic tags or even conditional attributes to add/remove elements, people often fall back on those two tags. Sometimes that's the only practical thing to do, but in your case or in any case where you have a 'switch' statement, you definitely want to use states.

Resources