Subject: [xsl] outputing elements correctly . From: Auguste Oumar <oumar_a@xxxxxxxx> Date: Thu, 13 Sep 2001 15:24:47 +0200 (CEST) |
Hi people, in spite of some meaningful tips from some of you,i can't manege to give the elements out properly.I think there is a basic thing about the processing of stylesheet i have not yet understood.If i use templates in my stylesheet,the output of the elements is correct but without the optional elements i also want to output with their default values.I have enclosed the xml-file(for the structure of the document) and the two stylesheet-files: One with templates(works correctly but without outputing optional elements) and the other one which doesn't work correctly.Can someone please tell me what i'm doing wrong ? Thanks. Auguste Xml-file: <?xml version="1.0" encoding="ISO-8859-1"?> <articleMasterData xmlns="http://www.Artikelstammdaten.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.Artikelstammdaten.org ArticleMaDaSch.xsd"> <?xml-stylesheet type="text/xsl" href="ArticleMaDaXmlToHtml.xsl"?> <?xml-stylesheet type="text/xsl" href="ArticleMaDaXmlToAscii.xsl"?> <telegramNumber>001100</telegramNumber> <client>123</client> <articleNumber>123456oumar</articleNumber> <itemCode>Hamburg-Germany</itemCode> <quantityPerPackingUnit>12345678</quantityPerPackingUnit> <QPPU-Modus>4</QPPU-Modus> <batchMode>5</batchMode> <quantityUnit>Pa</quantityUnit> <deliveryReferenz>00000089</deliveryReferenz> <price>134</price> <weight>65</weight> <height>15</height> <width>00000767</width> <depth>00000987</depth> <bestBeforeDate>20</bestBeforeDate> <pickingSequence>7</pickingSequence> <actionCode>2</actionCode> </articleMasterData> Stylesheet with templates: <?xml version="1.0" encoding="ISO8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:AMD="http://www.Artikelstammdaten.org" xmlns="http://www.w3.org/TR/REC-html40"> <xsl:output method="text"/> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="AMD:articleMasterData"> <xsl:apply-templates/> </xsl:template> <xsl:template match="AMD:telegramNumber"> <xsl:value-of select="."/></xsl:template> <xsl:template match="AMD:client"> <xsl:variable name="mandant" select="."/> <xsl:number value="$mandant" format="00000000"/></xsl:template> <xsl:template match="AMD:articleNumber"> <xsl:variable name="arNbr" select="."/> <xsl:value-of select="substring(concat($arNbr,' '),1,20)"/></xsl:template> <xsl:template match="AMD:itemCode"> <xsl:variable name="iCode" select="."/> <xsl:value-of select="substring(concat($iCode,' '),1,30)"/></xsl:template> <xsl:template match="AMD:itemCode2"> <xsl:variable name="iCode2" select="."/> <xsl:value-of select ="substring(concat($iCode2,' '),1,50)"/></xsl:template> <xsl:template match="AMD:quantityPerPackingUnit"> <xsl:variable name="qppu" select="."/> <xsl:number value="$qppu" format="00000000"/></xsl:template> <xsl:template match="AMD:QPPU-Modus"> <xsl:value-of select="."/></xsl:template> <xsl:template match="AMD:batchMode"> <xsl:value-of select="."/></xsl:template> <xsl:template match="AMD:quantityUnit"> <xsl:variable name="qUnit" select="."/> <xsl:value-of select="substring(concat($qUnit,' '),1,2)"/></xsl:template> <xsl:template match="AMD:deliveryReferenz"> <xsl:variable name="dRef" select="."/> <xsl:value-of select="substring(concat($dRef,' '),1,8)"/></xsl:template> <xsl:template match="AMD:price"> <xsl:variable name="prix" select="."/> <xsl:number value="$prix" format="00000000"/></xsl:template> <xsl:template match="AMD:weight"> <xsl:variable name="poids" select="."/> <xsl:number value="$poids" format="00000000"/></xsl:template> <xsl:template match="AMD:height"> <xsl:variable name="haut" select="."/> <xsl:number value="$haut" format="00000000"/></xsl:template> <xsl:template match="AMD:width"> <xsl:variable name="largeur" select="."/> <xsl:number value="$largeur" format="00000000"/></xsl:template> <xsl:template match="AMD:depth"> <xsl:variable name="profondeur" select="."/> <xsl:number value="$profondeur" format="00000000"/></xsl:template> <xsl:template match="AMD:bestBeforeDate"> <xsl:variable name="bbDate" select="."/> <xsl:number value="$bbDate" format="0000"/></xsl:template> <xsl:template match="AMD:pickingSequence"> <xsl:variable name="pseq" select="."/> <xsl:number value="$pseq" format="00"/></xsl:template> <xsl:template match="AMD:actionCode"> <xsl:value-of select="."/></xsl:template> </xsl:stylesheet> stylesheet without template(doesn't work properly): <?xml version="1.0" encoding="ISO8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:AMD="http://www.Artikelstammdaten.org" xmlns="http://www.w3.org/TR/REC-html40"> <xsl:output method="text"/> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="AMD:articleMasterData"> <xsl:if test="AMD:telegramNumber"> <xsl:value-of select="."/> </xsl:if> <xsl:if test="AMD:client"> <xsl:variable name="mandant" select="."/> <xsl:number value="$mandant" format="00000000"/> </xsl:if> <xsl:if test="AMD:articleNumber"> <xsl:variable name="arNbr" select="."/> <xsl:value-of select="substring(concat($arNbr,' '),1,20)"/> </xsl:if> <xsl:if test="AMD:itemCode"> <xsl:variable name="iCode" select="."/> <xsl:value-of select="substring(concat($iCode,' '),1,30)"/> </xsl:if> <xsl:choose> <xsl:when test="AMD:itemCode2"> <xsl:variable name="iCode2" select="."/> <xsl:value-of select ="substring(concat($iCode2,' '),1,50)"/> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="AMD:quantityPerPackingUnit"> <xsl:variable name="qppu" select="."/> <xsl:number value="$qppu" format="00000000"/> </xsl:when> <xsl:otherwise> <xsl:text>00000000</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:if test="AMD:QPPU-Modus"> <xsl:value-of select="."/> </xsl:if> <xsl:if test="AMD:batchMode"> <xsl:value-of select="."/> </xsl:if> <xsl:if test="AMD:quantityUnit"> <xsl:variable name="qUnit" select="."/> <xsl:value-of select="substring(concat($qUnit,' '),1,2)"/> </xsl:if> <xsl:choose> <xsl:when test="AMD:deliveryReferenz"> <xsl:variable name="dRef" select="."/> <xsl:value-of select="substring(concat($dRef,' '),1,8)"/> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text> </xsl:otherwise> </xsl:choose> <xsl:if test="AMD:price"> <xsl:variable name="prix" select="."/> <xsl:number value="$prix" format="00000000"/> </xsl:if> <xsl:choose> <xsl:when test="AMD:weight"> <xsl:variable name="poids" select="."/> <xsl:number value="$poids" format="00000000"/> </xsl:when> <xsl:otherwise> <xsl:text>00000000</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="AMD:height"> <xsl:variable name="haut" select="."/> <xsl:number value="$haut" format="00000000"/> </xsl:when> <xsl:otherwise> <xsl:text>00000000</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="AMD:width"> <xsl:variable name="largeur" select="."/> <xsl:number value="$largeur" format="00000000"/> </xsl:when> <xsl:otherwise> <xsl:text>00000000</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="AMD:depth"> <xsl:variable name="profondeur" select="."/> <xsl:number value="$profondeur" format="00000000"/> </xsl:when> <xsl:otherwise> <xsl:text>00000000</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:if test="AMD:bestBeforeDate"> <xsl:variable name="bbDate" select="."/> <xsl:number value="$bbDate" format="0000"/> </xsl:if> <xsl:choose> <xsl:when test="AMD:pickingSequence"> <xsl:variable name="pseq" select="."/> <xsl:number value="$pseq" format="00"/> </xsl:when> <xsl:otherwise> <xsl:text>00</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:if test="AMD:actionCode"> <xsl:value-of select="."/> </xsl:if> </xsl:template> </xsl:stylesheet> __________________________________________________________________ Do You Yahoo!? Gesendet von Yahoo! Mail - http://mail.yahoo.de XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Re[2]: correct use of key, Dylan Walsh | Thread | RE: [xsl] outputing elements correc, Michael Kay |
RE: [xsl] Re[2]: correct use of key, Dylan Walsh | Date | RE: [xsl] Re[2]: correct use of key, Dylan Walsh |
Month |