AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 27.04.2008, 18:07   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
axStart: How to use XSLT in AIF and what’s wrong with empty xml Nodes.
Источник: http://axstart.spaces.live.com/Blog/...C0A0!302.entry
==============


The AIF framework is able to communicate with XML messages to the outer world. However there is a small limitation. The format of this XML message should sometimes be altered for this outside world. Microsoft BizTalk can be a solution, when messages are send to different parties and every party has his own XML layout, but when this message has to be send to just one party XSLT can help you out.
XSLT is a mechanism that can rebuild an XML message to a different format (XML to XML or XML to xHTML).
It is possible in AX to use XSLT (BASIC\SETUP\AIF\XSLT Repository. You can use these XSLT in the Endpoint Actions Pipeline Components. The XSLT in AX can only transform the body node of the XML message.
It is also possible to use directly the XSLT from code:
XmlReader xslt = XmlReader::newFile(“Your file”);
XmlReader xml = XmlReader::newFile(“Your file”);
XmlDocument xmlDocument = xmlDocument::newXml(XmlTransform::execute(xslt,xml,false));
The best way to make an XSLT:
1 create an XSD that represent the body of the AX XML message (Altova MapForce)
2 get the XSD of the other party
3 Generate the XSLT with a tool like Altova MapForce.
4 Test the default AX XML and your XSLT in AX (form tutorial_XSL)
If you don’t have these tools you have to do it yourself. It is not so hard. Let’s have a look at next example: (generated with AIF table ProjValProjCategorySetUp)


Original
dmo

Design
Design


Design-R&D
91
Design


Install
Install
92


Let’s use next XSLT on it. It should generate a document with looks like a table. The first node is the table name, his child node has the name record and the child nodes record have the nodes of the fields CategoryID and ProjId.




















When processing this XSLT my XML will looks like:


Design



Design-R&D
91


Install
92


You are happy, you just generated your first XML transformation. But I have to disappoint you. A lot of tools that use your new XML document use XPATH technology. XPATH is some kind of query that can be used to select subsets out of your XML document. An XML query on your document could be: Give all CategoryId were also a ProjId exist.
/ProjValProjCategorySetUp/record[ProjId]/CategoryId
The query fails because what is is this equal to not exist or just a ProjID node with a value Empty? To avoid these situations, AIF skips by default all empty nodes (Look at the original XML document from AIF. The first group has no ProjId node.) If we also want to skip this empty node, we must adapt our XSLT document.



















But personally I like next solution:

















BLANK







Now I can use XPATH expressions /ProjValProjCategorySetUp/record[ProjId=’911’ or ProjId='BLANK']/CategoryId.
For more information about XSLT look at sites like http://www.topxml.com/xsl/tutorials/intro/default.asp and http://www.w3schools.com/xsl/


Источник: http://axstart.spaces.live.com/Blog/...C0A0!302.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
Теги
aif

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05
Dianne Siebold: AIF Top Ten Blog bot DAX Blogs 1 22.04.2008 11:19
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 20:35.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.