|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl grabbing specific data
Anton,
Thank you so much, looks like I have a lot to learn.
>From your example I have a much better understanding
of where I need to go. Only question I have now is say
that an xml has two identical trees, Like
<xml>
<name value="dan">
<name value="dan">
</xml>
Is there a way to stop the duplicaes during the
transform. I ran your transform and low and behold
boot.ini came to my results like above. Once again
thanks for the help.
Dan Sherman
--- cking <cking@xxxxxxxxxx> wrote:
> Hi Dan,
>
> Maybe you can create an additional xml-file, say
> 'files.xml':
>
> <files>
> <file>boot.ini</file>
> <file>compmgmt.msc</file>
> ...
> </files>
>
> And then use
>
> <xsl:variable name="files"
> select="document('files.xml')/files/file"/> and
> <xsl:if test="$files[contains(file-acl/@name,
> .)]">
>
> to extract only the files you want... something like
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" version="1.0"
> encoding="utf-8" indent="yes"/>
>
> <xsl:variable name="files"
> select="document('files.xml')/files/file"/>
>
> <xsl:template match="/">
> <list>
> <xsl:apply-templates
> select="//file-acl-list/file-acl"/>
> <!-- NOTE: if possible, pass absolute path rather
> than "//" -->
> </list>
> </xsl:template>
>
> <xsl:template match="file-acl">
> <xsl:if test="$files[contains(current()/@name,
> .)]">
> <xsl:variable name="filename">
> <xsl:call-template name="filename-from-path">
> <xsl:with-param name="name" select="@name"/>
> </xsl:call-template>
> </xsl:variable>
> <file name="{$filename}">
> <xsl:apply-templates select="ace"/>
> </file>
> </xsl:if>
> </xsl:template>
>
> <xsl:template match="ace">
> <xsl:if test="@is-grant = 'true'">
> <!-- or do whatever else to handle this -->
> <ace trustee="{@trustee}"/>
> </xsl:if>
> </xsl:template>
>
> <xsl:template name="filename-from-path">
> <xsl:param name="name"/>
> <xsl:choose>
> <xsl:when test="contains($name, '\')">
> <xsl:call-template name="filename-from-path">
> <xsl:with-param name="name"
> select="substring-after($name, '\')"/>
> </xsl:call-template>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="$name"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
> </xsl:stylesheet>
>
> HTH,
> Anton Triest
>
>
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
|
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
|

Cart








