Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Extracting Node Attributes
- This topic has 6 replies, 1 voice, and was last updated 9 years, 3 months ago by
community-content.
-
AuthorPosts
-
-
December 7, 2006 at 8:40 AM #16779
I have a flat file schema where all the data is in the attributes instead of in elements. In a Message Assignment shape I'm trying to get at the values of the attributes with something like the following:
Note.text = xpath(Notes, "/Note/@Narrative");
Or
Note.text = xpath(Notes, "/Note/@Narrative/string()");
These don't work unfortunately.
I was hoping to avoid creating another schema and mapping the attributes to actual elements. Anyone have any insights on how to grab the attribute value?
Thanks!
-
December 7, 2006 at 1:04 PM #16781
What happens if you grab the "Instance XPath" from the attribute in the schema file? Open your flat file schema, click the node you want, and look in the property window for Instance XPath. Copy that value and pass that in to the xpath query.
-
December 8, 2006 at 6:43 AM #16786
Thanks for the tip on the Instance XPath property.
When I put the value from the Instance XPath property in my xpath query, I get the following error.
Inner exception: The part 'text' of message 'AddNoteRequest' contained a null value at the end of the construct block.
Exception type: NullPartException
Source: Microsoft.XLANGs.EngineHere is the line in my Message Assignment shape that generates the error.
AddNoteRequest.text = xpath(NoteDto,"/*[local-name()='Note' and namespace-uri()='http://FlatFileTest.Notes'%5D/*%5Blocal-name()='Narrative' and namespace-uri()='']");
I double-checked my file and found no null characters in it.
The Microsoft KB says that the NullPartException comes from one orchestration calling another. This is not the case in my scenario.
I appreciate this help, but I'm still stuck.
Thanks!
-
December 8, 2006 at 7:07 AM #16791
Wait, what is "text" on AddNoteRequest? Is this a multi-part message? A distinguished field? Make sure you also provide a string/number conversion for the node you're extracting (see Stephen's post here .. http://www.geekswithblogs.net/sthomas/archive/2004/10/25/13269.aspx).
-
December 8, 2006 at 12:46 PM #16793
AddNoteRequest is a message that is being setup for a Web Service. ".text" is one the exposed properties for the Web Service call.
The NoteDto message refers to a simple flat file schema. There is only one "Note" node per NoteDto message. Neither of the messages are multi-part. AddNoteRequest.text is not a distinguished field since it is part of the Web Service call, but the "Narrative" attribute is a distinguished field at the moment.
When I dump the NoteDto message back out to a flat file after the construct message shape completes, the value of the attribute I'm trying to extract is there the same as at the start.
I've tried setting .text to some literal string and it works fine, so it has to be with the xpath query I'm using.
Thanks
-
December 11, 2006 at 6:30 AM #16826
I got it working. You nudges and good questions got me on the right track.
That Instance XPath property was the key to getting the right syntax in the xpath query. My final query looked like this if anyone is interested.
AddNoteRequest.text = xpath(WachNewAccount,"string(/*[local-name()='Header']/*[local-name()='AccountNew']/*[local-name()='NoteNew'][" + counterStr + "]/@*[local-name()='Narrative'])");
Thanks!
-
December 11, 2006 at 8:40 AM #16834
Nicely done. Good job.
-
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.