February 14th, 2012, 06:53 AM
Xml and xsl stylesheets
I don't really know if this is the correct forum for this. If it isn't, I apologise.
I'm trying to import some elements from an XML file into Adobe InDesign. I want to import the data, adding a decimal format and a "£" character, followed by a space. e.g. If the data is 23456.56 I want it to import "£ 23,456.56"
I can get the data in ok from the xml file but although the stylesheet is being read (I know this as it fails if I add some blatant errors) it won't do any formatting. I'm new to xml/xsl and the syntax is weird!
Anyone know what I'm doing wrong here? I'm sure it's obvious!
I've included the xml, dtd and xsl stylesheet file contents below. The xml currently contains just one lot of data.
Thanks, in antcipation for any replies!
This is an XML file called "CableNEWTEST.xml" and is a single portion of the data I wish to import
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE Root SYSTEM "catalogue.dtd">
<Prod_Description>quo dolecatume vendio es molupid qui consedis volorio. Itaturecab ilitatem excea solesero </Prod_Description>
This is the catalogue.dtd file containing the elements and the order they come in.
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT Root (Product) >
<!ELEMENT Product ( Prod_Stock_Code, Product_Image, Prod_GBP, Prod_Description ) >
<!ELEMENT Prod_Stock_Code (#PCDATA) >
<!ELEMENT Product_Image (#PCDATA) >
<!ELEMENT Prod_GBP (#PCDATA) >
<!ELEMENT Prod_Description (#PCDATA) >
This is the Stylesheet I'm using called "Stylesheet NEWTEST.xsl"
[code] Url is specified but I can't post it here!
<xsl:decimal-format name="Price" decimal-separator="." grouping-separator=","/>
<xsl:value-of select="format-number(Prod_GBP, '£ ###,###.00', 'Price')"/>
February 15th, 2012, 03:16 AM
Update to this post...
Originally Posted by gaztech46
I ran these files through the Oxygen XML Editor debugger and I find that the format number function is actually working fine. It seems that what is "not" happening is that the new value is not being passed back to the xml output so therefore it doesn't appear in my InDesign document.
I read up about this and it seems that the "apply-templates select" function does "select" the item but in order to get it back to the xml output I have to put it in a variable using syntax similar to "Product/Prod_GBP/@someVariable"
However, I don't know how to do this.
Does anyone here know how to do this?
Any advice would be appreciated.
February 15th, 2012, 09:08 AM
It would appear that InDesign can't do what I'm expecting it to do. The only way to achieve what I'm expecting is to transform the XML output into a NEW, corrected xml file (that includes all the transformation stuff) and then import that. It can't be done on the fly. Adobe DO lead you to believe that it does - but it doesn't!
Very annoying and has wasted a load of time but at least I now know what to do. I was hoping to get the result with a single process. Now it seems that I'll have to do a two step process to get the job done. I thought technology was supposed to be getting easier!
Thanks to all those that read the post anyway.