Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. removing unwanted empty XML elements (this one contains code in a legible form)

removing unwanted empty XML elements (this one contains code in a legible form)

Scheduled Pinned Locked Moved XML / XSL
xmlregexhelpquestionannouncement
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Craig Irwin
    wrote on last edited by
    #1

    Any help on this one would be appreciated as it is doing my head in As you will see by the "Current Output" I am generating unwanted translation tags containing the substring character generated in one of my for-each loops as it loops over my "Sample input" I have a habit of getting this stuff inside out and back to front and am pretty sure the solution is staring me in the face in such an "obvious" fashion that I can't see it The code I currently have ----------------------------- <pre><?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">       <xsl:output method="xml" indent="yes"/>       <!-- declaring 2 variables to hold "from" and "to" values -->       <xsl:variable name="from_what" select="Dictionary/@from"/>       <xsl:variable name="to_what" select="Dictionary/@to"/>       <xsl:template match="/">             <!-- hard coded task2.xsd reference -->             <Dictionary xsi:noNamespaceSchemaLocation="something.xsd" from="{$from_what}" to="{$to_what}">                                     <!-- outer loop to get a sorted search list -->                   <xsl:for-each select="//dictionaryEntry">                         <xsl:sort select="search"/>                                                 <xsl:element name="translation">                               <!-- substring the search string down to its                                     first character for the "initial" attribute-->              &nb

    B 1 Reply Last reply
    0
    • C Craig Irwin

      Any help on this one would be appreciated as it is doing my head in As you will see by the "Current Output" I am generating unwanted translation tags containing the substring character generated in one of my for-each loops as it loops over my "Sample input" I have a habit of getting this stuff inside out and back to front and am pretty sure the solution is staring me in the face in such an "obvious" fashion that I can't see it The code I currently have ----------------------------- <pre><?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">       <xsl:output method="xml" indent="yes"/>       <!-- declaring 2 variables to hold "from" and "to" values -->       <xsl:variable name="from_what" select="Dictionary/@from"/>       <xsl:variable name="to_what" select="Dictionary/@to"/>       <xsl:template match="/">             <!-- hard coded task2.xsd reference -->             <Dictionary xsi:noNamespaceSchemaLocation="something.xsd" from="{$from_what}" to="{$to_what}">                                     <!-- outer loop to get a sorted search list -->                   <xsl:for-each select="//dictionaryEntry">                         <xsl:sort select="search"/>                                                 <xsl:element name="translation">                               <!-- substring the search string down to its                                     first character for the "initial" attribute-->              &nb

      B Offline
      B Offline
      brifiction
      wrote on last edited by
      #2

      hi craig, i was wondering if you've already solved this problem? cause i too have another problem similar to this one but only has something similar with your line:

      <xsl:for-each select="search[not(.=preceding::search)]">

      i understand that you'll get like in your current output this line:

      <translation initial="A" />

      simply, how did you solve yours? (if you have solved it). i would appreciate it if you can post it. please and thanks!

      modified on Sunday, April 25, 2010 12:33 AM

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups