[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: cross reference call of templates in xslt
At 2008-12-17 20:29 +0100, Michael Richter wrote:
Hi, I have a XSL-Stylesheet: ... My XML-File as Input: ... Now my Result: ?xml version="1.0" encoding="UTF-8"?> <X> <Dokument> <Primaerdokument> <Dateiname>test (080011538) (080011547).txt</Dateiname> </Primaerdokument> I did not get this result running the stylesheet that you posted. And the data in your <Dateiname> result element does not match anything in your source. So I just guessed at some of your results. So i need the information of the part of "Adresse" put into the part of "Primaerdokument". Yes ... XSLT is so powerful it can create any XML structure output from any XML structure input ... the question is how easy is it? Note I am speaking of structure and vocabulary, not syntax. And what do i need to change in my XSLT-File? I'm doing the Transformatino in Java with javax.xml.transform.Transformer There were a number of faults in the stylesheet including incorrect addresses and the use of a named template instead of a matching template. And even then at the lower level it seemed you were using non-existent elements. I hope the code below helps. . . . . . . . . Ken t:\ftemp>type richter.xml <?xml version="1.0" encoding="UTF-8"?> <X> <Daten> <Dokument> <Primaerdokument> <Dateiname>test.txt</Dateiname> </Primaerdokument> <Adress_Informationen> <Absender> <Referenz>d1139077-ed5b-4be8-9eaa-775ab4052c5c</Referenz> </Absender> </Adress_Informationen> </Dokument> <Adresse> <Name> <Name_ID>1234567890</Name_ID> <Anrede>a</Anrede> </Name> <Anschrift> <Strasse>i</Strasse> </Anschrift> </Adresse> </Daten> </X> t:\ftemp>call xslt richter.xml richter.xsl <?xml version="1.0" encoding="utf-8"?> <X xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xdo="http://www.xdomea.de"> <Dokument> <Primaerdokument> <Dateiname>test.txt</Dateiname> </Primaerdokument> <Name_ID>1234567890</Name_ID> <adr_name>a</adr_name> <adr_anrede>i</adr_anrede> </Dokument> </X> t:\ftemp>type richter.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xdo="http://www.xdomea.de"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" /> <xsl:template match="/"> <xsl:for-each select="/X"> <X> <xsl:for-each select="Daten/Dokument"> <Dokument> <xsl:call-template name="dokument"/> </Dokument> </xsl:for-each> </X> </xsl:for-each> </xsl:template> <xsl:template name="dokument"> <Primaerdokument> <xsl:copy-of select="./Primaerdokument/Dateiname"/> </Primaerdokument> <xsl:call-template name="AdressenInfo" /> </xsl:template> <xsl:template name="AdressenInfo"> <xsl:if test="./Adress_Informationen/Absender/Referenz"> <xsl:apply-templates select="../../Daten/Adresse"> <xsl:with-param name="referenceID" select="./Adress_Informationen/Absender/Referenz" /> </xsl:apply-templates> </xsl:if> </xsl:template> <xsl:template match="Adresse"> <xsl:param name="referenceID" /> <Name_ID><xsl:value-of select="./Name/Name_ID" /></Name_ID> <adr_name><xsl:value-of select="./Name/Anrede" /></adr_name> <adr_anrede><xsl:value-of select="./Anschrift/Strasse" /></adr_anrede> </xsl:template> </xsl:stylesheet> t:\ftemp>rem Done! -- Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes: : Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video sample lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg Video course overview: http://www.youtube.com/watch?v=VTiodiij6gE G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|