Subject: RE: [xsl] passing_cousin_content_as_counter From: mankar@xxxxxxxxxxxxxxx Date: Mon, 2 Aug 2004 16:37:52 +0300 |
Hallo Mr Kay, Please excuse me for bothering you again, but i am close to presenting my MSc dissertation project and being under a lot of pressure, i find my self getting stuck with things that i would normally manage to confront with, under diferrent circumstances. My new question and hope the last related to the current project i am working relates to the code for comparing numbers to node-sets that you send me yesterday. The source xml is the one following, slightly diferrent from the one i sent you yesterday(it just includes and a second SHAPE element). <?xml version="1.0" encoding="ISO-8859-7"?> <ROWSET> <ROW num="1"> <SHAPE> <ELEM_INFO> <ELEM_INFO_ITEM>1</ELEM_INFO_ITEM> <ELEM_INFO_ITEM>1003</ELEM_INFO_ITEM> <ELEM_INFO_ITEM>1</ELEM_INFO_ITEM> </ELEM_INFO> <ORDINATES> <ORDINATES_ITEM>483639.599589384</ORDINATES_ITEM> <ORDINATES_ITEM>4314480.8582032</ORDINATES_ITEM> <ORDINATES_ITEM>483653.418277397</ORDINATES_ITEM> <ORDINATES_ITEM>4314497.09551522</ORDINATES_ITEM> <ORDINATES_ITEM>483696.866709438</ORDINATES_ITEM> <ORDINATES_ITEM>4314548.14836326</ORDINATES_ITEM> <ORDINATES_ITEM>483639.599589384</ORDINATES_ITEM> <ORDINATES_ITEM>4314480.8582032</ORDINATES_ITEM> </ORDINATES> </SHAPE> </ROW> <ROW num="2"> <SHAPE> <ELEM_INFO> <ELEM_INFO_ITEM>1</ELEM_INFO_ITEM> <ELEM_INFO_ITEM>1003</ELEM_INFO_ITEM> <ELEM_INFO_ITEM>1</ELEM_INFO_ITEM> <ELEM_INFO_ITEM>13</ELEM_INFO_ITEM> <ELEM_INFO_ITEM>2003</ELEM_INFO_ITEM> <ELEM_INFO_ITEM>1</ELEM_INFO_ITEM> </ELEM_INFO> <ORDINATES> <ORDINATES_ITEM>483168.460580946</ORDINATES_ITEM> <ORDINATES_ITEM>4314454.74669918</ORDINATES_ITEM> <ORDINATES_ITEM>483171.116692948</ORDINATES_ITEM> <ORDINATES_ITEM>4314465.79279519</ORDINATES_ITEM> <ORDINATES_ITEM>483183.52147696</ORDINATES_ITEM> <ORDINATES_ITEM>4314517.37383524</ORDINATES_ITEM> <ORDINATES_ITEM>483168.460580946</ORDINATES_ITEM> <ORDINATES_ITEM>4314454.74669918</ORDINATES_ITEM> <ORDINATES_ITEM>483198.743348974</ORDINATES_ITEM> <ORDINATES_ITEM>4314725.56217143</ORDINATES_ITEM> <ORDINATES_ITEM>483198.594772974</ORDINATES_ITEM> <ORDINATES_ITEM>4314728.70069943</ORDINATES_ITEM> <ORDINATES_ITEM>483192.709572968</ORDINATES_ITEM> <ORDINATES_ITEM>4314852.93913155</ORDINATES_ITEM> <ORDINATES_ITEM>483198.743348974</ORDINATES_ITEM> <ORDINATES_ITEM>4314725.56217143</ORDINATES_ITEM> </ORDINATES> </SHAPE> </ROW> </ROWSET> I am using the following stylesheet to select all ORDINATE_ITEM contents in a string as the content of a new polygon element of the output xml. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="/"> <PolygonSet> <xsl:for-each select="ROWSET/ROW"> <polygon> <xsl:for-each select="SHAPE/ORDINATES/ORDINATES_ITEM"> <xsl:choose> <xsl:when test="position() mod 2 = 1"> <xsl:value-of select="format-number(.,'#')"/> <xsl:text>,</xsl:text> </xsl:when> <xsl:when test="position() mod 2 = 0"> <xsl:value-of select="format-number(.,'#')"/> <xsl:text> </xsl:text> </xsl:when> </xsl:choose> </xsl:for-each> </polygon> </PolygonSet> </xsl:template> </xsl:stylesheet> This results to an xml output like the one following: <?xml version="1.0" encoding="UTF-8"?> <PolygonSet> <polygon>483640,4314481 483653,4314497 483697,4314548 483640,4314481 </polygon> <polygon>483168,4314455 483171,4314466 483184,4314517 483203,4314600 483205,4314605 483168,4314455 483199,4314726 483199,4314729 483193,4314853 483199,4314726 </polygon> </PolygonSet> If now i also want to make use of the code you sent me in order to mark ORDINATE_ITEM element's content whose position is specified like : position() = /ROWSET/ROW/SHAPE/ELEM_INFO/ELEM_INFO_ITEM[position() mod 3 = 1] by adding a d infront of them, can it be achieved through this same stylesheet? I tried adding another <xsl:when statement to the when node-set of the previous stylesheet like <xsl:when test="position() = /ROWSET/ROW/SHAPE/ELEM_INFO/ELEM_INFO_ITEM[position() mod 3 = 1]> <xsl:text>d</xsl:text><xsl:value-of select="."/> </xsl:when> or <xsl:when test="position() = /ROWSET/ROW/SHAPE/ELEM_INFO/ELEM_INFO_ITEM[position() mod 3 = 1]> <xsl:value-of select="concat('d',.)"/> </xsl:when> but it didn't work. I also tried adding a second template to the previous stylesheet like: <xsl:template match="SDO_ORDINATES_ITEM[position() = /ROWSET/ROW/SHAPE/SDO_ELEM_INFO/SDO_ELEM_INFO_ITEM[position() mod 3 = 1]]"> <xsl:copy> <xsl:text>d</xsl:text> <xsl:value-of select="."/> </xsl:copy> </xsl:template> but it was also ignored. The output i am aftering will just have the character d added in front of the relevant ORDINATE_ITEM values in the polygon content string: <?xml version="1.0" encoding="UTF-8"?> <PolygonSet> <polygon>d483640,4314481 483653,4314497 483697,4314548 483640,4314481 </polygon> <polygon>d483168,4314455 483171,4314466 483184,4314517 483203,4314600 483205,4314605 483168,4314455 d483199,4314726 483199,4314729 483193,4314853 483199,4314726 </polygon> </PolygonSet> Do you think that i will definitely have to use a second stylesheet in order to obtain this output, or can it also be managed through the same stylesheet? I understand i may be making questions with obvious answers but i don't think that my mind works properly right now. Please send me any comments, and excuse me if i have bothered you again for something obvious. Regards Manousos Athens
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] passing_cousin_content_as, mankar | Thread | RE: [xsl] passing_cousin_content_as, Michael Kay |
Re: [xsl] how to take table data?, Mulberry Technologie | Date | RE: [xsl] passing_cousin_content_as, Michael Kay |
Month |