Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: include document and concatanated id's

From: Martin <a@-.->
To: NULL
Date: 4/7/2008 1:47:00 PM

Oh wicked! That did the trick.

Thanks very much Martin.

Martin Honnen wrote:
> Martin wrote:
> 
>> I need to change this xsl to combine id's (if present) so i get:
>>
>> ----- result -----
>> <component id='mainProduct'>
>              ^^^^^^^^^^^^^^^
> 
> It is not clear where that id comes from.
> 
>>     <assembly id='main$outerBox' width='400'>
>>         <name'>Cardboard Outer</name>
>>         <price id='main$outerPrice' value='200' />
>>     </assembly>
>> </component>
> 
> Here is an XSLT 1.0 stylesheet processing the nodes to be changed in a 
> different mode and passing in the "prefix" as a parameter:
> 
> <xsl:stylesheet
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   version="1.0">
> 
>   <xsl:output method="xml"/>
> 
>   <xsl:template match="component">
>     <xsl:copy>
>       <xsl:apply-templates/>
>     </xsl:copy>
>   </xsl:template>
> 
>   <xsl:template match="parts">
>     <xsl:apply-templates select="document(@url)/*" mode="fix">
>       <xsl:with-param name="prefix" select="@id"/>
>     </xsl:apply-templates>
>   </xsl:template>
> 
>   <xsl:template match="*" mode="fix">
>     <xsl:param name="prefix"/>
>     <xsl:copy>
>       <xsl:apply-templates select="@* | node()" mode="fix">
>         <xsl:with-param name="prefix" select="$prefix"/>
>       </xsl:apply-templates>
>     </xsl:copy>
>   </xsl:template>
> 
>   <xsl:template match="@id" mode="fix">
>     <xsl:param name="prefix"/>
>     <xsl:attribute name="id">
>       <xsl:value-of select="concat($prefix, '$', .)"/>
>     </xsl:attribute>
>   </xsl:template>
> 
>   <xsl:template match="@* | text() | comment() | 
> processing-instruction()" mode="fix">
>     <xsl:copy/>
>   </xsl:template>
> 
> </xsl:stylesheet>
> 
> When applied to your input (with some errors corrected) the result is
> 
> 
> <component>
>     <assembly id="main$outerBox" width="400">
>     <name>Cardboard Outer</name>
>     <price id="main$outerPrice" value="200"/>
> </assembly>
> </component>
> 
> which is what you described, with the exception of the component element 
> where I am not sure the id is supposed to come from.
> 
> 


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent