Subject: [xsl] Parse CDATA content From: "Lopez, William" <william.lopez@xxxxxxx> Date: Tue, 15 Apr 2003 08:24:33 -0500 |
Hello List: Here's what I'm trying to do: Create a HTML report from an Ant log file. I'd like to parse the <![CDATA[]]> section of the message elements. The characters that signal an element I want has '<-', then I want to grab everything after 'SourceCompare' until the '<-' but not including it. Then, I want to break out the 1st "node" after that so I end up with 2 tokens, example element: <![CDATA[//server/PVCS_Data/Build/Integration/SourceCompare/BatchJobs/com/cl ient/ECreator.java <- //server/Production/archives/BatchJobs/com/client/ECreator.java-arc]]> Resulting in: BatchJobs (token 1), com/client/ECreator.java (token 2) Then, the next message after that contains the version of that class as such: <message priority="info"><![CDATA[rev 1.21]]></message> I need the contents from that...I think using text() would give me that but I need that on the same "row" so the table output looks like this: Projects Class Version BatchJobs com/client/ECreator.java rev 1.21 This log file is approximately 6 - 7 MB but the pertinent info need (in this case are just six lines) is much less which is why I'd like to produce this report. I can get to the <target> element I want but after that I hit the wall. XML snippet: <build> <target> ... <task> ... <target name="retrieveJavaFromPVCS"> <task name="pvcs" time="5 minutes 7 seconds"> <message priority="warn"> <![CDATA[PVCS Version Manager (get) v6.8.00 (Build 128) for Windows NT/80x86]]> </message> <message priority="info"><![CDATA[Creating folders]]></message> <message priority="info"><![CDATA[Getting Files]]></message> <message priority="debug"><![CDATA[Considering ""\Production\archives\BatchJobs\com\DebugSink.java-arc""]]> </message> <message priority="info"> <![CDATA[//server/PVCS_Data/Build/Integration/SourceCompare/BatchJobs/com/cl ient/ECreator.java <- //server/Production/archives/BatchJobs/com/client/ECreator.java-arc]]> </message> <message priority="info"><![CDATA[rev 1.21]]></message> </task> </target> ... </task> ... </target> </build> XSL: <xsl:template match="build"> ... <xsl:apply-templates select="/build/target/task/target[@name='retrieveJavaFromPVCS']"/> ... </xsl:template> <xsl:template match="/build/target/task/target/task[@name='pvcs']"> <xsl:for-each select="message[@priority='info']"> <tr valign="top"> <xsl:attribute name="class"> <xsl:if test="position() mod 2 = 1">a</xsl:if> <xsl:if test="position() mod 2 = 0">b</xsl:if> </xsl:attribute> <td nowrap="yes" width="1%">Project Name</td> <td nowrap="yes" style="text-align:right" width="1%">Class Path</td> <td class="{@priority}" nowrap="yes">Version : <xsl:value-of select="text()"/></td> </tr> </xsl:for-each> </xsl:template> <!-- attempt to find start and stop points to grab string but don't know how to finish it --> <!-- adapted code from XSLT Cookbook --> <xsl:template name="start-pt"> <xsl:param name="search-arg" select="SourceCompare"/> <xsl:param name="input-arg"/> <xsl:choose> <xsl:when test="contains($input-arg,$search-arg)"> <xsl:value-of select="string-length(substring-before($input-arg,$search-arg))"/> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:template> <!-- <xsl:template name="end-pt"> <xsl:param name="search-arg" select="<-"/> <!-- trying to escape greater than char that makes up the arrow --> <xsl:param name="input-arg"/> <xsl:choose> <xsl:when test="contains($input-arg,$search-arg)"> <xsl:value-of select="string-length(substring-before($input-arg,$search-arg))"/> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:template> --> Thanks, -Will XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] worng xsl:sort by numbers, John Barden | Thread | [xsl] copy html from xml to html, Luke Ambrogio |
RE: [xsl] xslt2 grouping, Andrew Welch | Date | Re: [xsl] xslt2 grouping, David Carlisle |
Month |