2 Replies Latest reply on Dec 3, 2009 7:08 AM by Belton

    XML import - can you select based on the absence of an attribute ?



      XML import - can you select based on the absence of an attribute ?



      I'm a relative novice, FM10, OSX 10.5,

      I've been following goodhope's threads on xml import and have learned a lot. I am probably one step away from the import I wish to do. 


      My problem is this; there is a group of data tagged <meaning> that has a subset with an attribute giving the language. 

      I am only interested in the English which does not have an associated attribute. 

      Also the number of entries from  record to record is variable. Sometimes no entries, sometimes 5 or more. Nor is it at a fixed position in the record as earlier entries are also variable in number.


      At present I use this but it picks up every instance of <meaning>

      (In the example "ten、dix、diez、10、dez、" when I only want to import "ten" )


      <xsl:for-each select="reading_meaning/rmgroup/meaning">
      <xsl:value-of select="." />


      Is there any way to specify only the value without an attribute or to omit the values that have an attribute ?


      I could grep the original file to insert an  m_lang="en" attribute. 

      I could also use FM's functions to subtract the french, spanish, portugese, etc values after import

      However I would like to try to understand XSLT and do it at this stage if possible. 


      A sample record

      <cp_value cp_type="ucs">5341</cp_value>
      <cp_value cp_type="jis208">29-29</cp_value>
      <rad_value rad_type="classical">24</rad_value>
      <dic_ref dr_type="nelson_c">768</dic_ref>
      <dic_ref dr_type="nelson_n">598</dic_ref>
      <dic_ref dr_type="halpern_njecd">3365</dic_ref>
      <dic_ref dr_type="halpern_kkld">2110</dic_ref>
      <dic_ref dr_type="heisig">10</dic_ref>
      <dic_ref dr_type="gakken">5</dic_ref>
      <dic_ref dr_type="oneill_names">18</dic_ref>
      <dic_ref dr_type="oneill_kk">12</dic_ref>
      <dic_ref dr_type="moro" m_vol="2" m_page="0479">2695</dic_ref>
      <dic_ref dr_type="henshall">33</dic_ref>
      <dic_ref dr_type="sh_kk">12</dic_ref>
      <dic_ref dr_type="sakade">10</dic_ref>
      <dic_ref dr_type="jf_cards">25</dic_ref>
      <dic_ref dr_type="henshall3">10</dic_ref>
      <dic_ref dr_type="tutt_cards">6</dic_ref>
      <dic_ref dr_type="crowley">22</dic_ref>
      <dic_ref dr_type="kanji_in_context">10</dic_ref>
      <dic_ref dr_type="busy_people">1.A</dic_ref>
      <dic_ref dr_type="kodansha_compact">239</dic_ref>
      <dic_ref dr_type="maniette">10</dic_ref>
      <q_code qc_type="skip">4-2-3</q_code>
      <q_code qc_type="sh_desc">2k0.1</q_code>
      <q_code qc_type="four_corner">4000.0</q_code>
      <q_code qc_type="deroo">1455</q_code>
      <reading r_type="pinyin">shi2</reading>
      <reading r_type="korean_r">sib</reading>
      <reading r_type="korean_h">십</reading>
      <reading r_type="ja_on">ジュウ</reading>
      <reading r_type="ja_on">ジッ</reading>
      <reading r_type="ja_on">ジュッ</reading>
      <reading r_type="ja_kun">とお</reading>
      <reading r_type="ja_kun">と</reading>
      <meaning m_lang="fr">dix</meaning>
      <meaning m_lang="es">diez</meaning>
      <meaning m_lang="es">10</meaning>
      <meaning m_lang="pt">dez</meaning>




      supplemental question

      Is there an elegant way to avoid the last text used a seperator in the list generated by 


      <xsl:for-each select="reading_meaning/rmgroup/meaning">
      <xsl:value-of select="." />