|  | 
 
  
    | RSS Feed - WebSphere MQ Support | RSS Feed - Message Broker Support |  
 
  
	|    |  |  
  
	| DFDL modeling elements with unknown names | « View previous topic :: View next topic » |  
  	| 
		
		
		  | Author | Message |  
		  | rekarm01 | 
			  
				|  Posted: Fri Apr 13, 2018 5:38 pm    Post subject: DFDL modeling elements with unknown names |   |  |  
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 1415
 
 
 | 
			  
				| Given a (simplified) sample message like: 
 
 
   
	| Code: |  
	| Prop1=Val1 Prop2=Val2
 Prop3=Val3
 ...
 |  To preserve backwards compatibility with existing usage, I want the parsed tree structure to look something like:
 
 
 
   
	| Code: |  
	| <Prop1>Val1</Prop1> <Prop2>Val2</Prop2>
 <Prop3>Val3</Prop3>
 ...
 |  except that the names of the elements aren't necessarily known in advance, so I can't enumerate them in the DFDL schema.  I tried using regular expressions with dfdl:lengthPattern, something like:
 
 
 
   
	| Code: |  
	| <xsd:element dfdl:lengthKind="pattern" dfdl:lengthPattern="[A-Z][A-Za-z0-9]+" name="???" ... > |  but that seems more useful for setting the value of an element, rather than the name.  I also tried using dfdl:initiator to set the value for a dfdl variable, something like:
 
 
 
   
	| Code: |  
	| <xsd:element dfdl:initiator="[A-Z][A-Za-z0-9]+" name="{$elemName}" ... > |  but couldn't quite figure out how to both set and use a dfdl variable within the scope of the same element.
 
 How can DFDL model elements like this, where the names of the elements are provided in the data?
 |  |  
		  | Back to top |  |  
		  |  |  
		  | timber | 
			  
				|  Posted: Sat Apr 14, 2018 2:55 am    Post subject: |   |  |  
		  |  Grand Master
 
 
 Joined: 25 Aug 2015Posts: 1292
 
 
 | 
			  
				| One of the rules of DFDL is that the element names must be known in advance. Supporting XML Schema wildcards (xs:any, abstract types etc) would have been extremely difficult to specify properly, and would be used very rarely. 
 I would model your format like this:
 
 
   
	| Code: |  
	| message sequence delimiter=%NL;
 field maxOccurs=unbounded
 sequence delimiter='='
 fieldName
 fieldValue
 |  Not exactly the XML structure that you were aiming for, but it would be simple to restructure the message tree if that matters.
 |  |  
		  | Back to top |  |  
		  |  |  
		  | rekarm01 | 
			  
				|  Posted: Sat Apr 14, 2018 11:28 am    Post subject: |   |  |  
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 1415
 
 
 | 
			  
				| 
   
	| timber wrote: |  
	| One of the rules of DFDL is that the element names must be known in advance. |  I suspected that, but I wasn't sure.
 
 
 
   
	| timber wrote: |  
	| I would model your format like this ... Not exactly the XML structure that you were aiming for, ... |  Not exactly, no, but it seems like the best available option.  Thanks for your help.
 |  |  
		  | Back to top |  |  
		  |  |  
		  |  |  |  
  
	|    |  | Page 1 of 1 |  
 
 
  
  	| 
		
		  | 
 
 | You cannot post new topics in this forum You cannot reply to topics in this forum
 You cannot edit your posts in this forum
 You cannot delete your posts in this forum
 You cannot vote in polls in this forum
 
 |  |  |  |