[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: indenting maps on write
On Tue, Apr 02, 2024 at 09:19:29PM -0000, Michael Kay michaelkay90@xxxxxxxxx scripsit: > Well, `file:write` isn't going to add any whitespace, it will be some process prior to that (which you haven't shown us). If I boil the whole thing down to a simple example, if I start with: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet exclude-result-prefixes="xs math xd" version="3.0" xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xd:doc scope="stylesheet"> <xd:desc> <xd:p><xd:b>Created on:</xd:b> Apr 2, 2024</xd:p> <xd:p><xd:b>Author:</xd:b> graydon</xd:p> <xd:p /> </xd:desc> </xd:doc> <xsl:variable name="punctuationNameMap" select=" map { ',': 'comma', ';': 'semicolon', ':': 'colon', '.': 'period' }" static="yes" /> <xsl:variable as="xs:string" name="instanceNumber" select="'000112'" /> </xsl:stylesheet> and use this as the source document for <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xs math xd" version="3.0"> <xd:doc scope="stylesheet"> <xd:desc> <xd:p><xd:b>Created on:</xd:b> Apr 2, 2024</xd:p> <xd:p><xd:b>Author:</xd:b> graydon</xd:p> <xd:p></xd:p> </xd:desc> </xd:doc> <xsl:mode on-no-match="shallow-copy"/> <xd:doc> <xd:desc>increment the instance number</xd:desc> </xd:doc> <xsl:template match="xsl:variable[@name eq 'instanceNumber']/@select"> <xsl:attribute name="select" select="'''' || ((replace(.,'''','') => number() => xs:integer()) + 1) => format-number('000000') => string() || ''''" /> </xsl:template> </xsl:stylesheet> I get <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xs math xd" version="3.0"> <xd:doc scope="stylesheet"> <xd:desc> <xd:p><xd:b>Created on:</xd:b> Apr 2, 2024</xd:p> <xd:p><xd:b>Author:</xd:b> graydon</xd:p> <xd:p/> </xd:desc> </xd:doc> <xsl:variable name="punctuationNameMap" select=" map { ',': 'comma', ';': 'semicolon', ':': 'colon', '.': 'period' }" static="yes"/> <xsl:variable as="xs:string" name="instanceNumber" select="'000113'"/> </xsl:stylesheet> I would like the punctuationNameMap variable to look in the result document as it does in the source document. -- Graydon -- Graydon Saunders | graydonish@xxxxxxxxxxxx ^fs oferiode, pisses swa mfg. -- Deor ("That passed, so may this.")
|
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
|