RE: How to copy a string containing attributes into an
Don't try to serialize the attributes yourself (as a string), let Saxon do the work for you. Create the attributes as nodes, not as strings. Since you're using syntax that's special to Saxon already, you really might as well move to XSLT 2.0 and use the replacement for these constructs proposed in the current working drafts. The natural thing to do would then be for your function to return a sequence of attribute nodes, like this: <xsl:function name="fun:GetAppearance" as="attribute()*"> <xsl:param name="appearance"/> <xsl:attribute name="border" select="fun:GetBorder(XPATH)"/> <xsl:attribute name="background-color" select="fun:getColor(XPATH)"/> <xsl:sequence select="fun:getMargin(XPATH)"/> </xsl:function> You can then attach these attributes to an element with: <fo:some-element> <xsl:sequence select="fun:getAppearance($a)"/> </fo:some-element> XSLT 1.0 doesn't allow freestanding attribute nodes, so the nearest equivalent would be to create an element, attach the new attributes to it, and return a temporary tree containing this element; you can then copy the attributes to a different element using <xsl:copy-of select="fun:getAppearance($a)/*/@*)"/>. Michael Kay > -----Original Message----- > From: Jan Kohnert [mailto:J.Kohnert@xxxxxxxxxxx] > Sent: 30 June 2004 15:22 > To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' > Subject: How to copy a string containing attributes > into an element? > > Hello List, > > In my stylesheet, I perform two steps to generate FO. First, > I dissolve any > references inside the XML source data, building an temporary > result tree. > Second, I apply over the temporary result tree, generating the FO code > itself. > > While dissolving the references I use saxon's "function" > extension to return > the dissolved values. > To apply succesfully over the tempory result tree, I need to store any > information stored in FO as attributes also as attributes in > the temporary > result tree. > > Therefor I want to copy a string as returned from the > function example below > into an element as a "attribute set": (X PATH is short for > the real X Path, > that is quite long..) > > <saxon:function name="fun:GetAppearance"> > <xsl:param name="appearance"/> > <xsl:variable name="Appearanceset"> > <xsl:value-of select="concat( 'border="', fun:GetBorder( > X PATH ), > '" ', > 'background-color="', > fun:GetColor( X > PATH ), '" ', > fun:GetMargin( X PATH ))"/> > > </xsl:variable> > <saxon:return select="$Appearanceset"/> > </saxon:function > > Returns (for example): > border="0.5pt solid #FFAAAA" background-color="#CDCDCD" margin="" > margin-top="5mm" margin-bottom="7mm" margin-right="2mm" > margin-left="5mm" > > (There is also a concat in "fun:GetMargin()" !) > > what I want is, for example, to put this string into an > <block-container> > element. > <block-container border="0.5pt solid #FFAAAA" > background-color="#CDCDCD" > margin="" margin-top="5mm" margin-bottom="7mm" margin-right="2mm" > margin-left="5mm" > > > Is this possible? and when, how? > > Thanks! > > --+------------------------------------------------------------------ > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ > or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> > --+-- > >
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