[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Newline problems
Thanks Mike, this to me seems like a novel way of doing it. I guess it would
be good to use this approach when there are very few elements from the src
xml that are not needed in the output xml i.e. I do not have too many
templates to ignore elements (just like you have here for BILL_TO_ADDRESS3).
As I believe I mentioned, the DOCTYPE, though empty is needed by the target system. About the template modes, they came in the sheet I inherited. I just retained them as I had a very limited mandate and I am only beginning to learn xsl, so I did not want to touch any thing that I was not sure of. '"/> <!-- go process the root node's children --> <xsl:apply-templates/> </xsl:template> Just an addition - I had to add an "!" before the DOCTYPE. <!-- when processing a Quote element, generate an Order element that contains the result of processing the Quote element's children --> <xsl:template match="Quote"> <Order> <xsl:apply-templates/> </Order> </xsl:template> When does this overridden text template get called. We do not seem to have any templates that explicitly match text(). Does it get auto called when any text is encountered? <!-- don't forget that there is a built-in template that we're relying on to handle the atomicValue elements (and any others that we didn't provide explicit templates for): it just results in the processing of the element's children; nothing is generated. It looks like this: <xsl:template match="*"> <xsl:apply-templates/> </xsl:template> --> Just for info, I am also posting here the other approach that Lars suggested: <?xml version = "1.0" encoding = "UTF-8"?> <xsl:transform xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0"> <xsl:template match = "Quote"> <xsl:text disable-output-escaping="yes"><!DOCTYPE Order></xsl:text> <xsl:element name = "Order"> <xsl:element name ="Info"> <xsl:apply-templates mode = "Attribs" select = "/Quote/Info"/> </xsl:element> </xsl:element> </xsl:template> <xsl:template mode = "Attribs" match = "Info"> <xsl:call-template name="atomicValue"> <xsl:with-param name="AVname" select="'BILL_TO_ADDRESS2'" /> </xsl:call-template> <xsl:call-template name="atomicValue"> <xsl:with-param name="AVname" select="'PO_NUMBER'" /> </xsl:call-template> </xsl:template> <xsl:template name="atomicValue"> <xsl:param name="AVname" select="''" /> <xsl:element name="{$AVname}"> <xsl:value-of select="attribute/atomicValue[normalize-space(../name)=$AVname]"/> </xsl:element> </xsl:template> </xsl:transform> Thanks Mike, Lars, Michael, David and all others who helped out. Vish. _________________________________________________________________ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|