Jump to content

Maunder

Members
  • Posts

    6
  • Joined

  • Last visited

Maunder's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Dear boen_robot,Yes, I did come up with this as a substitute for the distinct-values() function, which is not supported in my environment. Following is a 'moot court' example of the xml structure and xsl script for your consideration. Here is the xml: <?xml version="1.0" encoding="ISO-8859-1"?><!--The following line is not part of the original xml but facilitates previewing the solution during development. I use NoteTab Pro 4.95 for a text editor.--><?xml-stylesheet type="text/xsl" href="XSLtemp02.xsl"?><!--Following is a simplification of the original xml structure focused on the 'counting without duplicates' problem. Note that, in this case, the image nodes sections only appear where the image name has a comp extension, i.e. img20.comp. The comp extension is generated by the third-party software that produces the xml and refers to composite. Also, note that the images may be either jpg or tif and that such extensions may be either upper or lower case. Thus, I have used !=comp to avoid counting composites.--><OrdersByImages> <ImageOrders> <ImageName>img01.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img02.JPG</ImageName> </ImageOrders> <ImageOrders> <ImageName>img03.tif</ImageName> </ImageOrders> <ImageOrders> <ImageName>img04.JPG</ImageName> </ImageOrders> <ImageOrders> <ImageName>img05.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img06.TIF</ImageName> </ImageOrders> <ImageOrders> <ImageName>img07.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img08.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img09.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img10.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img11.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img12.comp</ImageName> <ImageNodes> <ImageNode> <ImageName>img12.jpg</ImageName> </ImageNode> </ImageNodes> </ImageOrders> <ImageOrders> <ImageName>img13.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img14.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img15.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img16.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img17.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img18.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img19.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img20.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img20.comp</ImageName> <ImageNodes> <ImageNode> <ImageName>img20.jpg</ImageName> </ImageNode> </ImageNodes> </ImageOrders> <ImageOrders> <ImageName>img22.comp</ImageName> <ImageNodes> <ImageNode> <ImageName>img21.jpg</ImageName> </ImageNode> </ImageNodes> </ImageOrders> <ImageOrders> <ImageName>img21.comp</ImageName> <ImageNodes> <ImageNode> <ImageName>img20.jpg</ImageName> </ImageNode> </ImageNodes> </ImageOrders> <ImageOrders> <ImageName>img23.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img23.comp</ImageName> <ImageNodes> <ImageNode> <ImageName>img23.tif</ImageName> </ImageNode> <ImageNode> <ImageName>img23.jpg</ImageName> </ImageNode> </ImageNodes> </ImageOrders> <ImageOrders> <ImageName>img26.comp</ImageName> <ImageNodes> <ImageNode> <ImageName>img26.jpg</ImageName> </ImageNode> </ImageNodes> </ImageOrders> <ImageOrders> <ImageName>img25.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img24.jpg</ImageName> </ImageOrders> <ImageOrders> <ImageName>img27.comp</ImageName> <ImageNodes> <ImageNode> <ImageName>img27.jpg</ImageName> </ImageNode> </ImageNodes> </ImageOrders></OrdersByImages>Here is the xsl: <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:key name="ImgFiles" match="//ImageOrders/ImageName[substring-after(text(),'.')!=comp] | //ImageOrders/ImageNodes/ImageNode/ImageName" use="text()"/><xsl:template match="/"><html><body><xsl:number value="count(//ImageOrders/ImageName[substring-after(text(),'.')!=comp])+count(//ImageOrders/ImageNodes/ImageNode/ImageName[text() != following::ImageOrders/ImageName])-count(//ImageOrders/ImageName[substring-after(text(),'.')!=comp][text() = following::ImageOrders/ImageNodes/ImageNode/ImageName])"/> </body></html></xsl:template></xsl:stylesheet>I hope this helps you and others. Maunder
  2. Thank you for responding to my quandary, aalbetski. Since posting it, I have devised and implemented the solution (Muenchianesque?) indicated below. Since this solution is not broken, I do not intend to fix it, but I do find your approach quite instructive and will keep it for future reference. <!-- In my solution the following appears in the style sheet prior to the template declaration--><xsl:key name="ImgFiles" match="//ImageOrders/ImageName[substring-after(text(),'.')!=comp] | //ImageOrders/ImageNodes/ImageNode/ImageName" use="text()"/><!-- Then the following is inserted in the style sheet where the count needs to appear--><xsl:number value="count(//ImageOrders/ImageName[substring-after(text(),'.')!=comp])+count(//ImageOrders/ImageNodes/ImageNode/ImageName[text() != following::ImageOrders/ImageName])-count(//ImageOrders/ImageName[substring-after(text(),'.')!=comp][text() = following::ImageOrders/ImageNodes/ImageNode/ImageName])"/>
  3. Thanks for the reply. I did try the solution described in the post you referenced, but IE 6.0 said the keyword "key", as in <xsl:key name="something"/> is not supported. Maunder
  4. The desired output is the count of unique image file names in an XML document that must be transformed with an XSL document. The file names that need to be counted are found along the two different paths specified below. List A of "ImageName" is gleaned from "//OrdersByImages/ImageOrders" andList B of "ImageName" is gleaned from "//OrdersByImages/ImageOrders/ImageNodes/ImageNode". The problem has, at least, two aspects. The first aspect is that some file names in List B may duplicate file names in List A, thus inflating the count, i.e. img01.jpg is in both List A and List B. The second aspect is that some file names in List B may duplicate other file names in List B, also inflating the count, i.e. img01.jpg appears twice in List B. Whether one or more duplicates of, for instance, img01.jpg, appears in List A and/or List B, the solution requires that no specific image file name be counted more than once.Any relevant advice or direction will be greathly appreciated.Thanks in advance for your response.Maunder mcross@mckennapro.com
×
×
  • Create New...