removing unwanted empty XML elements (this one contains code in a legible form)
-
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
-
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
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