how to create an Atom feed using EMML

jasav
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 06/13/2010
Points: 10

Hi,

  I am very new at mashups and emml and this might be very easy for most of you guys. I am creating a mashup that sends out a Atom feed however inside the <content> tag , my custom tag <data> is getting an empty xmlns value even if in emml I definitely did not put that definition. below is the emml code snippet:

<foreach items = "$sqlResult/records/record" variable="content">
                   
          <appendresult outputvariable="sqlToRSS">
                  <data>
                  {$content/*}
                  </data>

          </appendresult>
      </foreach>
      
     <constructor outputvariable="result">
        <feed xmlns="http://www.w3.org/2005/Atom">
         <link href="http://localhost:8080/resources/timezones" rel="self"/>
            <title>Payglobal Atom feed</title>
            <id>http://mstest3.com:8080/payglobal</id>
            <author>
                <name>user</name>
                <email>user@test.com</email>
            </author>
            <entry>
                  <title>Employee data</title>
                <link></link>
                <summary>Data for company</summary>
                <category>Employees</category>
                <id></id>
                <content>
                      {$sqlToRSS/*/*}
                  </content>
              </entry>
        </feed>
     </constructor>

 

Below is what I get from the result:

 

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <link href="http://localhost:8080/resources/timezones" rel="self"/>
   <title>Payglobal Atom feed</title>
   <id>http://mstest3.com:8080/payglobal</id>
   <author>
      <name>user</name>
      <email>user@test.com</email>
   </author>
   <entry>
      <title>Employee data</title>
      <link/>
      <summary>Data for company</summary>
      <category>Employees</category>
      <id/>
      <content>
         <data xmlns="">

             ......

         </data>

     </content>

 </entry>

</feed>

 

How can I get the 'xmlns=""'  out in my <data xmlns=''> tag?

0
Your rating: None
aishmishra
aishmishra's picture
User offline. Last seen 10 weeks 6 days ago. Offline
Joined: 09/24/2008
Points: 3

Hi Jasper,

Can you tell me if the added empty namespace definition is causing any problems in you using the atom feed? We would still investigate the issue but curious to know.

Aishwarya

smitchell
smitchell's picture
User offline. Last seen 16 hours 22 min ago. Offline
Joined: 08/29/2008
Points: 34

Like Aishwarya, it would be interesting to know if this actually causes a problem since Atom is by definition supposed to carry content that is not in the Atom namespace. And that is at least why xmlns="" is showing up.

In XML, a blank namespace declaration gets added when a child node has no namespace and  its parent does. It basically says "this is in the default namespace." So the result in your variable is not in the Atom namespace. My limited understanding of Atom is that <content> is allowed to contain HTML or any well-formed XML in any namespace -- which should include the default namespace.

Sara, technical writer/jackbe

 

jasav
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 06/13/2010
Points: 10

Thanks for you replies.

The current result would display properly in the browser though I should have constructed my atom feed properly as the current one will display all of the resulted rows in a single entry.I was trying to display each sql result row as one entry. below are the changes I made

 <sql outputvariable="sqlResult" query="$sqltoExecute" name="employeesFeed"
         startrow="{$startcnt}" rowcount="20" />
 
      <foreach items = "$sqlResult/records/record" variable="content">
                   
          <appendresult outputvariable="sqlToRSS">
              <entry>
                  <title>{$content/lastname/text()}</title>
                <link></link>
                <summary>{concat($content/preferredname/text(),' ', $content/lastname/text(), ' employment information')}</summary>
                <category>{$content/alliedacademicindicator/text()}</category>
                <id>{$content/employeeid/text()}</id>
                <content>
                <hr:data>
                  <hr:loginid>{$content/loginid/text()}</hr:loginid>
            <hr:employeeid>{$content/employeeid/text()}</hr:employeeid>
            <hr:legaltitle>{$content/legaltitle/text()}</hr:legaltitle>
            <hr:firstname>{$content/firstname/text()}</hr:firstname>
            <hr:lastname>{$content/lastname/text()}</hr:lastname>
            <hr:preferredname>{$content/preferredname/text()}</hr:preferredname>
                  </hr:data>
                  </content>
              </entry>
          </appendresult>
      </foreach>
      
     <constructor outputvariable="result">
        <feed xmlns="http://www.w3.org/2005/Atom">
         <link href="http://localhost:8080/resources/timezones" rel="self"/>
            <title>Payglobal Atom feed</title>
            <id>http://mstest3.com:8080/payglobal</id>
            <author>
                <name>user name</name>
                <email>user@mail.com</email>
            </author>
            {$sqlToRSS/*/*}
                 
        </feed>
     </constructor>

However, the same thing happens but now it inserts the empty namespace definition in the <entry> tag. With the empty namespace define in the <entry> tag, this does not display properly in the browser, my guess is that is not a well-formed atom feed. So I took Sara's explaination of the child node and put a namespace definition on the entry tag like below

<foreach items = "$sqlResult/records/record" variable="content">
                   
          <appendresult outputvariable="sqlToRSS">
              <entry xmlns="http://www.w3.org/2005/Atom">
                    <title>{$content/lastname/text()}</title>
                <link></link>
                <summary>{concat($content/preferredname/text(),' ', $content/lastname/text(), ' employment information')}</summary>
                <category>{$content/alliedacademicindicator/text()}</category>
                <id>{$content/employeeid/text()}</id>
                <content>
                    <hr:loginid>{$content/loginid/text()}</hr:loginid>
                        <hr:employeeid>{$content/employeeid/text()}</hr:employeeid>
                        <hr:legaltitle>{$content/legaltitle/text()}</hr:legaltitle>
                        <hr:firstname>{$content/firstname/text()}</hr:firstname>
                        <hr:lastname>{$content/lastname/text()}</hr:lastname>
                            <hr:preferredname>{$content/preferredname/text()}</hr:preferredname>
                </content>
              </entry>
 
 It solved the namespace issue (as you can see no more empty namespace in the <entry> tag) but the next problem is that it did not display the xpath value of variable 'content' (see below)
 
  ...
  <author>
       <name>user name</name>
       <email>username@mail.com</email>
    </author>
    <entry>
       <title/>
       <link/>
       <summary>  employment information</summary>
       <category/>
       <id/>
       <content>
          <hr:data xmlns:hr="http://ww.hr.org/empdata">
             <hr:loginid/>
             <hr:employeeid/>
             <hr:legaltitle/>
             <hr:firstname/>
             <hr:lastname/>
            <hr:preferredname/>
       </content>
       ....
      
            
 Sorry if my reply is too long, can't explain it very much without showing the code and result. I tried a lot of things to fix this. Also tried to remove the namespace in the <feed> tag whci produced a clean atom feed but wo't display in the browser so I tried to use annotate to put the namespace after the feed was constructed but same thing happens (empty namespace definition).
 Hope you can help me out.

smitchell
smitchell's picture
User offline. Last seen 16 hours 22 min ago. Offline
Joined: 08/29/2008
Points: 34

Hi Jasper,

We think you may have found a bug, but we're attempting to confirm that and see if we have a work around. So, we haven't forgotten...just working on it.

Sara, technical writer/jackbe

 

raj
raj's picture
User offline. Last seen 1 week 4 days ago. Offline
Joined: 09/22/2008
Points: 4

 Hi Jasper,

The xpath expressions embedded in appendresult get evaluated in the namespace context of container element. Since a default namespace (xmlns) is defined for <entry/> element, all embedded xpath expressions use this as their default namespaces in their evaluation (as per XQuery semantics). 

So can you change the xpath expressions to use wildcard namespaces and re-try i.e.,

For example, change

                    <title>{$content/lastname/text()}</title>

to

                    <title>{$content/*:lastname/text()}</title>

 

<foreach items = "$sqlResult/records/record" variable="content">
                    
          <appendresult outputvariable="sqlToRSS">
              <entry xmlns="http://www.w3.org/2005/Atom"> 
                    <title>{$content/*:lastname/text()}</title>
                <link></link>
                <summary>{concat($content/*:preferredname/text(),' ', $content/*:lastname/text(), ' employment information')}</summary>
                <category>{$content/*:alliedacademicindicator/text()}</category>
                <id>{$content/*:employeeid/text()}</id>
                <content>
                    <hr:loginid>{$content/*:loginid/text()}</hr:loginid>
                        <hr:employeeid>{$content/*:employeeid/text()}</hr:employeeid>
                        <hr:legaltitle>{$content/*:legaltitle/text()}</hr:legaltitle>
                        <hr:firstname>{$content/*:firstname/text()}</hr:firstname>
                        <hr:lastname>{$content/*:lastname/text()}</hr:lastname>
                            <hr:preferredname>{$content/*:preferredname/text()}</hr:preferredname>
                </content>

              </entry> 

 

Let us know how it goes.

raj.  chief masher @ jackbe

jasav
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 06/13/2010
Points: 10

Hi Raj,

 Thanks! that did the trick =)  However, will that be always the case when using appendresult on atom feed?

Thanks,

  Jasper

jasav
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 06/13/2010
Points: 10

Thanks Sara! if it is a bug, looking forward for the patch =)

smitchell
smitchell's picture
User offline. Last seen 16 hours 22 min ago. Offline
Joined: 08/29/2008
Points: 34

It would apply to <appendresult> anywhere it is used when you have literal XML with a declared namespace and dynamic mashup expressions inside. It also applies to <constructor> if you use literal XML and dynamic mashup expressions to populate the variable for <constructor>.

Sara, technical writer/jackbe