2222import java .util .List ;
2323import java .util .Map ;
2424import java .util .stream .Collectors ;
25+ import java .util .regex .Pattern ;
2526
2627import static java .util .Arrays .asList ;
2728import static java .util .Collections .emptyMap ;
@@ -42,7 +43,12 @@ static Map<String, String> parseAttributes(String name) {
4243 if (!name .contains (" " ))
4344 return emptyMap ();
4445 Map <String , String > attributes = new HashMap <>();
45- String [] words = name .split (" " );
46+
47+ // Regex to split on spaces, ignoring spaces inside quoted text
48+ final String SPACE_OUTSIDE_QUOTES_REGEX = " (?=(?:[^\" ]*\" [^\" ]*\" )*[^\" ]*$)" ;
49+ Pattern spaceOutsideQuotesPattern = Pattern .compile (SPACE_OUTSIDE_QUOTES_REGEX );
50+ String [] words = spaceOutsideQuotesPattern .split (name );
51+
4652 for (String word : asList (words ).subList (1 , words .length )) {
4753 String [] parts = word .split ("(?<!\\ ))=(\" |')" , 2 );
4854 attributes .put (parts [0 ], parts [1 ].substring (0 , parts [1 ].length () - 1 ));
@@ -135,16 +141,7 @@ static XFormsElement select1(String ref, XFormsElement... children) {
135141 }
136142
137143 static XFormsElement select1Dynamic (String ref , String nodesetRef ) {
138- XFormsElement value = t ("value ref=\" value\" " );
139- XFormsElement label = t ("label ref=\" label\" " );
140-
141- HashMap <String , String > itemsetAttributes = new HashMap <>();
142- itemsetAttributes .put ("nodeset" , nodesetRef );
143- TagXFormsElement itemset = new TagXFormsElement ("itemset" , itemsetAttributes , asList (value , label ));
144-
145- HashMap <String , String > select1Attributes = new HashMap <>();
146- select1Attributes .put ("ref" , ref );
147- return new TagXFormsElement ("select1" , select1Attributes , asList (itemset ));
144+ return select1Dynamic (ref , nodesetRef , "value" , "label" );
148145 }
149146
150147 static XFormsElement select1Dynamic (String ref , String nodesetRef , String valueRef , String labelRef ) {
0 commit comments