 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 23rd, 2008, 03:51 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Did you read the second half of my previous post?
/- Sam Judson : Wrox Technical Editor -/
|
|

July 23rd, 2008, 04:12 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes, i had read your second half of your previous post.
Your right, the template "createAccessFeesPeriods" obviously isn't returning any elements.
If i tired to call the template createAccessFeesPeriods directly just for debugging,Output is
*Test*
*Test*
*Test*
[u]Question</u>: The result of template will not appear within variable? I mean after the <xsl:call-template name="createAccessFeesPeriods"/> get executed. I am expecting the output of variable as follows, but its not happening.. i hope my expectation is wrong...? some alternative solution?
<xsl:variable name="VariantA">
<AccessFeesGroupList>
<AccessFeesGroup>
<Period dateFrom='<>' dateTo='<>' discountValue='<>' invoiceLineValue='<>' vatValue='<>' />
</AccessFeesGroup>
</AccessFeesGroupList>
</xsl:variable>
<xsl:template match="/">
<xsl:call-template name="createAccessFeesPeriods"/>
</xsl:template>
<xsl:template name="createAccessFeesPeriods">
<xsl:for-each select="Document/Invoice/InvoiceItem/AggSet/Att[@Ty='TM'][generate-id() = generate-id(key('by-id', @Id)[1])]">
<AccessFeesGroup> *Test*
<Period dateFrom='20080202' dateTo='' discountValue='' invoiceLineValue='' vatValue=''/>
</AccessFeesGroup>
</xsl:for-each>
</xsl:template>
|
|

July 23rd, 2008, 05:03 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Again, I cannot see anything wrong with your code - but you are not showing us your input document!
For the third time of asking, please can you post a sample of your input document (you know, the one with all the Invoice items in!)
/- Sam Judson : Wrox Technical Editor -/
|
|

July 23rd, 2008, 05:13 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for your patience.
Find the sample input document.
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<Invoice>
<Date Type="INV" Date="20080428" />
<Date Type="START" Date="20060101" />
<Date Type="END" Date="20080427" HH="23" MM="59" SS="59" />
<InvoiceItem CT="A" >
<AggSet>
<Att Ty="TM" Id="WLCO" />
<Att Ty="SP" Id="WLSC" />
<Att Ty="SN" Id="GTEL" />
<Att Ty="MRKT" Id="GSM" />
</AggSet>
<Charge Id="99" Amount="136.7700" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="125" Amount="136.7700" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="203" Amount="164.1200" CurrCode="EUR" Type="9" PT="P" />
</InvoiceItem>
<InvoiceItem CT="A" >
<AggSet>
<Att Ty="TM" Id="WLCO" />
<Att Ty="SP" Id="WLSC" />
<Att Ty="SN" Id="GTEL" />
<Att Ty="MRKT" Id="GSM" />
</AggSet>
<Charge Id="99" Amount="136.7700" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="125" Amount="136.7700" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="203" Amount="164.1200" CurrCode="EUR" Type="9" PT="P" />
</InvoiceItem>
<InvoiceItem CT="A" >
<AggSet>
<Att Ty="TM" Id="VMA1" />
<Att Ty="SP" Id="GBA1" />
<Att Ty="SN" Id="GSMS" />
<Att Ty="MRKT" Id="GSM" />
</AggSet>
<Charge Id="99" Amount="4.0000" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="125" Amount="4.0000" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="203" Amount="4.8000" CurrCode="EUR" Type="9" PT="P" />
</InvoiceItem>
<InvoiceItem CT="O" >
<AggSet>
<Att Ty="TM" Id="OCCRP" />
<Att Ty="SP" Id="OS" />
<Att Ty="SN" Id="DUNN" />
<Att Ty="MRKT" Id="EDS" />
</AggSet>
<Charge Id="99" Amount="0.0000" CurrCode="EUR" Type="9" PT="P" />
<Charge Id="125" Amount="0.0000" CurrCode="EUR" Type="5" PT="P" />
<Charge Id="203" Amount="0.0000" CurrCode="EUR" Type="9" PT="P" />
</InvoiceItem>
</Invoice>
</Document>
|
|

July 23rd, 2008, 05:23 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
Right, well using your input document above, with your stylesheet above (the one you have marked as "complete") it works fine for me (outputs "200802022008020220080202" which is the partial date 3 times).
I simply cut and pasted into notepad, and then ran using Xalan command line.
/- Sam Judson : Wrox Technical Editor -/
|
|

July 23rd, 2008, 05:31 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Oh!....
But its not working with me... Which version of xalan did u executed?
I am not using any external xalan, just using builtin of java 1.5.0_12.
If u r running through command line, please give me the same version of xalan link which you are using to execute it.?
|
|

July 23rd, 2008, 05:40 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
I used the latest one from the Xalan web site. I'm not very experience with java, but as the code is working it must be something to do with the way you are implementing it in Java.
Can you post the code you are using to run the stylesheet?
/- Sam Judson : Wrox Technical Editor -/
|
|

July 23rd, 2008, 05:47 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Your using xalan-c or xalan-J ? Whats the command that u r using to run the xsl file ?
Find the code below,
package ASCII;
import javax.xml.transform.Source;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationExcept ion;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;
public class ConvertToASCII{
public static void main(String[] arguments) {
TransformerFactory factory =
TransformerFactory.newInstance();
String xslStream = "file.xsl";
String xmlStream = "file.xml";
String outputStream = "output.txt";
Source xsl = new StreamSource(xslStream);
Source xml = new StreamSource(xmlStream);
// Result result = new StreamResult(outputStream);
javax.xml.transform.Result result = new javax.xml.transform.stream.StreamResult(System.out );
try {
Templates template = factory.newTemplates(xsl);
Transformer transformer = template.newTransformer();
transformer.transform(xml, result);
} catch (TransformerConfigurationException e) {
System.out.println("xsl: TransformerConfigurationException: "+e.getMessage());
} catch (TransformerException e) {
System.out.println("xml: TransformerException: "+e.getMessage());
}
}
}
|
|

July 23rd, 2008, 05:55 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
java -cp xalan.jar org.apache.xalan.xslt.Process -IN test.xml -XSL test.xsl
outputs:
200802022008020220080202
http://xml.apache.org/xalan-j/
/- Sam Judson : Wrox Technical Editor -/
|
|

July 23rd, 2008, 06:08 AM
|
|
Authorized User
|
|
Join Date: Jul 2008
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Wow !
Its working with the command line of xalan-j_2_7_0. But why not with my builtin xalan of Java 1.5.0_12. Need to be analysed but at the moment no time.
|
|
 |