[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] "group-starting-with" and "analyze-string" alternative
I have written an XSLT for the source below that works well in XSLT 2.0. However, the application with which I need to use it (MindJet MindManager 7) only supports MSXMLtherefore, it doesnt support 2.0. Ive tried it. No go. So how can I do this in XSLT 1.0? Specifically: 1. Im using for-each-group with group-starting-with to create a nested hierarchy of elements that are designated by a level attribute in the source file, but otherwise flat. Ive read up on Muenchian grouping, but havent been able to figure out a good work-around. I havent found a 1.0 grouping discussion that addresses this kind of grouping. 2. Im using the analyze-string and regex to reformat the HTML in the CDATA sections to correctly insert double-quotes and a few other things. There must be a work-around for XSLT 1.0, but thinking about it makes my brain hurt. Thanks for any help. Sample Source File: <?xml version="1.0"?> <lbx-annotations category="Annotations" name="Sample Note File" guid="{D3670131-D9C9-49EA-A392-B31AA2FA7A68}"> <metadata> <document created="2007-08-09T01:33:14Z" modified="2007-08-20T03:20:38Z"/> <internal-version>2006-01-04T21:13:23Z</internal-version> </metadata> <annotation guid="{7C100949-A771-4B0E-8669-7850CEB20FC4}" created="2007-08-20T03:17:19Z" modified="2007-08-20T03:20:06Z" author="John Q. Author (Email@xxxxxxxxxx)" type="comment" style="highlight" color="auto" state="not-posted" level="2"> <title>Out of Place Note 1</title> <content><![CDATA[]]></content> </annotation> <annotation guid="{AFFC91C5-13EE-438B-9BF8-1C5B32B92146}" created="2007-08-20T03:19:33Z" modified="2007-08-20T03:19:59Z" author="John Q. Author (Email@xxxxxxxxxx)" type="comment" style="highlight" color="auto" state="not-posted" level="3"> <title>Out of Place Note 1a</title> <content><![CDATA[]]></content> </annotation> <annotation guid="{27129A7B-8EB9-4995-BB8E-5FFAAD9FEE5A}" created="2007-08-09T01:33:19Z" modified="2007-08-11T17:50:00Z" author="John Q. Author (Email@xxxxxxxxxx)" type="comment" style="highlight" color="auto" state="not-posted" level="0"> <title>Sample Note 1</title> <content type="text/html"><![CDATA[]]></content> </annotation> <annotation guid="{2A62112A-8C9E-4182-9769-D7A8B51A9A90}" created="2007-08-09T01:33:44Z" modified="2007-08-09T01:36:16Z" author="John Q. Author (Email@xxxxxxxxxx)" type="support" style="highlight" color="silver" state="not-posted" level="1"> <title>Sample Note 1a</title> <content type="text/html"><![CDATA[]]></content> </annotation> <annotation guid="{F14A3BFB-683D-443B-B3C9-18834E643919}" created="2007-08-09T01:34:25Z" modified="2007-08-09T01:36:44Z" author="John Q. Author (Email@xxxxxxxxxx)" type="issue" style="highlight" color="lime" state="not-posted" level="0"> <title>Sample Note 2</title> <content type="text/html"><![CDATA[]]></content> </annotation> <annotation guid="{270CCA03-20DC-4B43-81E6-F4CEC5BBB8C4}" created="2007-08-09T01:34:46Z" modified="2007-08-09T01:36:58Z" author="John Q. Author (Email@xxxxxxxxxx)" type="question" style="highlight" color="cyan" state="not-posted" level="0"> <title>Sample Note 3</title> <content type="text/html"><![CDATA[]]></content> </annotation> <annotation guid="{B8451892-B89D-4F66-AEEB-E2A4F5482A38}" created="2007-08-09T01:35:36Z" modified="2007-08-09T01:37:26Z" author="John Q. Author (Email@xxxxxxxxxx)" type="support" style="highlight" color="purple" state="not-posted" level="2"> <title>Sample Note 3b</title> <content type="text/html"><![CDATA[<P align=left></P> <DIV style="MARGIN-TOP: 18pt; MARGIN-BOTTOM: 18pt; LINE-HEIGHT: normal; TEXT-ALIGN: center"><B><SPAN lang=en-us><SPAN style="FONT-SIZE: 166%; FONT-FAMILY: Arial"></SPAN></SPAN></B><B><SPAN lang=en-us><SPAN style="FONT-SIZE: 166%; TEXT-TRANSFORM: capitalize; FONT-FAMILY: Arial"><FONT size=6>FOREWORD BY OLAN HENDRIX</FONT></SPAN></SPAN></B></DIV> <DIV style="TEXT-INDENT: 18pt; LINE-HEIGHT: normal; TEXT-ALIGN: left"><B><SPAN lang=en-us><SPAN style="FONT-SIZE: 166%; FONT-FAMILY: Arial"></SPAN></SPAN></B><SPAN lang=en-us>In more than twenty years in the ministry few books have influenced and helped me more than A. B. Bruces </SPAN><I><SPAN lang=en-us>The Training of the Twelve.</SPAN></I><SPAN lang=en-us> I was delighted to discover that Kregel Publications was planning to reissue this very valuable book, and I thank God for their foresight in this undertaking. With confidence and enthusiasm I commend this volume to my fellow ministers throughout the English speaking world.</SPAN></DIV><A title="" style="mso-footnote-id: ftn1" href="lbxfile:C:%5CProgram%20Files%5CLibronix%20DLS%5CCommon%5CLDLS%5CShells% 5CLDLS-en.lbxshl+AnnotationTemplate/Standard.html#_ftn1" name=_ftnref1><SPAN style="VERTICAL-ALIGN: super"><SPAN style="mso-special-character: footnote"></SPAN></SPAN></A> <DIV style="mso-element: footnote-list"> <DIV id=ftn1 style="mso-element: footnote"> <DIV style="MARGIN: 0in"><A title="" style="mso-footnote-id: ftn1" href="lbxfile:C:%5CProgram%20Files%5CLibronix%20DLS%5CCommon%5CLDLS%5CShells% 5CLDLS-en.lbxshl+AnnotationTemplate/Standard.html#_ftnref1" name=_ftn1><SPAN style="VERTICAL-ALIGN: super"><SPAN style="mso-special-character: footnote"></SPAN></SPAN></A><SPAN id=__spanCitationData>Bruce, A. B. (1995, c1877). <I>The training of the twelve or, Passages out of the Gospels, exhibiting the twelve disciples of Jesus under discipline for the apostleship</I> (0). Oak Harbor, WA: Logos Research Systems, Inc.</SPAN></DIV></DIV></DIV>]]></content> </annotation> </lbx-annotations> XSLT 2.0 file: <?xml version="1.0"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003"; xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003"; xmlns:pri="http://schemas.mindjet.com/MindManager/Primitive/2003"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> <xsl:output method="xml" /> <!-- ========================================================================== --> <xsl:template match="/"> <ap:Map> <!-- xsi:schemaLocation="http://schemas.mindjet.com/MindManager/Application/2003 http://schemas.mindjet.com/MindManager/Application/2003 http://schemas.mindjet.com/MindManager/Core/2003 http://schemas.mindjet.com/MindManager/Core/2003 http://schemas.mindjet.com/MindManager/Delta/2003 http://schemas.mindjet.com/MindManager/Delta/2003 http://schemas.mindjet.com/MindManager/Primitive/2003 http://schemas.mindjet.com/MindManager/Primitive/2003";>--> <ap:OneTopic> <ap:Topic> <ap:SubTopics> <xsl:for-each-group select="/lbx-annotations/annotation" group-starting-with="*[@level=0]"> <xsl:call-template name="do-annotation"> <xsl:with-param name="thisGroup" select="current-group()"/> <xsl:with-param name="targetLevel" select="@level + 1"/> </xsl:call-template> </xsl:for-each-group> </ap:SubTopics> <ap:Text> <xsl:attribute name="PlainText"><xsl:value-of select="/lbx-annotations/@name"/></xsl:attribute> <ap:Font/> </ap:Text> </ap:Topic> </ap:OneTopic> </ap:Map> </xsl:template> <xsl:template match="annotation" name="do-annotation"> <xsl:param name="thisGroup"/> <xsl:param name="targetLevel"/> <ap:Topic> <ap:SubTopics> <xsl:for-each-group select="current-group()[@level >= $targetLevel]" group-starting-with="*[@level=$targetLevel]"> <xsl:call-template name="do-annotation"> <xsl:with-param name="thisGroup" select="current-group()"/> <xsl:with-param name="targetLevel" select="$targetLevel +1"/> </xsl:call-template> </xsl:for-each-group> </ap:SubTopics> <ap:TopicViewGroup ViewIndex="0"> <ap:Collapsed Collapsed="true"/> <ap:DataContainerVisibility Collapsed="true"/> </ap:TopicViewGroup> <ap:Text TextAlignment="urn:mindjet:Left"> <xsl:attribute name="PlainText"><xsl:apply-templates select="$thisGroup[1]/title" mode="text"/></xsl:attribute> <ap:Font/> </ap:Text> <xsl:apply-templates select="$thisGroup[1]/content"/> <ap:Offset CY="0."> <xsl:attribute name="CX"><xsl:choose><xsl:when test="position() <= last() div 2">30</xsl:when><xsl:otherwise>-30</xsl:otherwise></xsl:choose></xsl:attribut e> </ap:Offset> </ap:Topic> </xsl:template> <xsl:template match="content"> <ap:NotesGroup> <ap:NotesXhtmlData> <xsl:attribute name="PreviewPlainText"><xsl:value-of select="concat(substring(.,1,75),' . . .')" disable-output-escaping="yes"/></xsl:attribute> <html xmlns="http://www.w3.org/1999/xhtml";> <xsl:analyze-string select="." regex="=(\#[0-f]{{6}}|[A-z]+\-[A-z]+|[A-z]+|\d+|.[A-z]+\d+|\_\_[A-z]+)\>"> <xsl:matching-substring> <xsl:value-of select='concat("=""",regex-group(1),"""")' disable-output-escaping="yes"/> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:analyze-string select="." regex="(&[a-z]{{4}};)"> <xsl:matching-substring> <xsl:value-of select='replace(".",regex-group(1)," ")' disable-output-escaping="yes"/> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="." disable-output-escaping="yes"/> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:non-matching-substring> </xsl:analyze-string> </html> </ap:NotesXhtmlData> </ap:NotesGroup> </xsl:template> <xsl:template match="*"> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet> Sample Output File: <?xml version="1.0" encoding="UTF-8"?> <ap:Map xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003"; xmlns:cor="http://schemas.mindjet.com/MindManager/Core/2003"; xmlns:pri="http://schemas.mindjet.com/MindManager/Primitive/2003"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> <ap:OneTopic> <ap:Topic> <ap:SubTopics> <ap:Topic> <ap:SubTopics> <ap:Topic> <ap:SubTopics /> <ap:TopicViewGroup ViewIndex="0"> <ap:Collapsed Collapsed="true" /> <ap:DataContainerVisibility Collapsed="true" /> </ap:TopicViewGroup> <ap:Text TextAlignment="urn:mindjet:Left" PlainText="Out of Place Note 1a"> <ap:Font /> </ap:Text> <ap:NotesGroup> <ap:NotesXhtmlData PreviewPlainText=" . . ."> <html xmlns="http://www.w3.org/1999/xhtml"; /> </ap:NotesXhtmlData> </ap:NotesGroup> <ap:Offset CY="0." CX="-30" /> </ap:Topic> </ap:SubTopics> <ap:TopicViewGroup ViewIndex="0"> <ap:Collapsed Collapsed="true" /> <ap:DataContainerVisibility Collapsed="true" /> </ap:TopicViewGroup> <ap:Text TextAlignment="urn:mindjet:Left" PlainText="Out of Place Note 1"> <ap:Font /> </ap:Text> <ap:NotesGroup> <ap:NotesXhtmlData PreviewPlainText=" . . ."> <html xmlns="http://www.w3.org/1999/xhtml"; /> </ap:NotesXhtmlData> </ap:NotesGroup> <ap:Offset CY="0." CX="30" /> </ap:Topic> <ap:Topic> <ap:SubTopics> <ap:Topic> <ap:SubTopics /> <ap:TopicViewGroup ViewIndex="0"> <ap:Collapsed Collapsed="true" /> <ap:DataContainerVisibility Collapsed="true" /> </ap:TopicViewGroup> <ap:Text TextAlignment="urn:mindjet:Left" PlainText="Sample Note 1a"> <ap:Font /> </ap:Text> <ap:NotesGroup> <ap:NotesXhtmlData PreviewPlainText=" . . ."> <html xmlns="http://www.w3.org/1999/xhtml"; /> </ap:NotesXhtmlData> </ap:NotesGroup> <ap:Offset CY="0." CX="-30" /> </ap:Topic> </ap:SubTopics> <ap:TopicViewGroup ViewIndex="0"> <ap:Collapsed Collapsed="true" /> <ap:DataContainerVisibility Collapsed="true" /> </ap:TopicViewGroup> <ap:Text TextAlignment="urn:mindjet:Left" PlainText="Sample Note 1"> <ap:Font /> </ap:Text> <ap:NotesGroup> <ap:NotesXhtmlData PreviewPlainText=" . . ."> <html xmlns="http://www.w3.org/1999/xhtml"; /> </ap:NotesXhtmlData> </ap:NotesGroup> <ap:Offset CY="0." CX="30" /> </ap:Topic> <ap:Topic> <ap:SubTopics /> <ap:TopicViewGroup ViewIndex="0"> <ap:Collapsed Collapsed="true" /> <ap:DataContainerVisibility Collapsed="true" /> </ap:TopicViewGroup> <ap:Text TextAlignment="urn:mindjet:Left" PlainText="Sample Note 2"> <ap:Font /> </ap:Text> <ap:NotesGroup> <ap:NotesXhtmlData PreviewPlainText=" . . ."> <html xmlns="http://www.w3.org/1999/xhtml"; /> </ap:NotesXhtmlData> </ap:NotesGroup> <ap:Offset CY="0." CX="-30" /> </ap:Topic> <ap:Topic> <ap:SubTopics> <ap:Topic> <ap:SubTopics> <ap:Topic> <ap:SubTopics /> <ap:TopicViewGroup ViewIndex="0"> <ap:Collapsed Collapsed="true" /> <ap:DataContainerVisibility Collapsed="true" /> </ap:TopicViewGroup> <ap:Text TextAlignment="urn:mindjet:Left" PlainText="Sample Note 3b"> <ap:Font /> </ap:Text> <ap:NotesGroup> <ap:NotesXhtmlData PreviewPlainText="<P align=left></P>
<DIV style="MARGIN-TOP: 18pt; MARGIN-BOTTOM: 18pt; LINE- . . ."> <html xmlns="http://www.w3.org/1999/xhtml";> <P align="left" /> <DIV style="MARGIN-TOP: 18pt; MARGIN-BOTTOM: 18pt; LINE-HEIGHT: normal; TEXT-ALIGN: center"> <B> <SPAN lang="en-us"> <SPAN style="FONT-SIZE: 166%; FONT-FAMILY: Arial" /> </SPAN> </B> <B> <SPAN lang="en-us"> <SPAN style="FONT-SIZE: 166%; TEXT-TRANSFORM: capitalize; FONT-FAMILY: Arial"> <FONT size="6">FOREWORD BY OLAN HENDRIX</FONT> </SPAN> </SPAN> </B> </DIV> <DIV style="TEXT-INDENT: 18pt; LINE-HEIGHT: normal; TEXT-ALIGN: left"> <B> <SPAN lang="en-us"> <SPAN style="FONT-SIZE: 166%; FONT-FAMILY: Arial" /> </SPAN> </B> <SPAN lang="en-us">In more than twenty years in the ministry few books have influenced and helped me more than A. B. Bruces </SPAN> <I> <SPAN lang="en-us">The Training of the Twelve.</SPAN> </I> <SPAN lang="en-us"> I was delighted to discover that Kregel Publications was planning to reissue this very valuable book, and I thank God for their foresight in this undertaking. With confidence and enthusiasm I commend this volume to my fellow ministers throughout the English speaking world.</SPAN> </DIV> <A title="" style="mso-footnote-id: ftn1" href="lbxfile:C:%5CProgram%20Files%5CLibronix%20DLS%5CCommon%5CLDLS%5CShells% 5CLDLS-en.lbxshl+AnnotationTemplate/Standard.html#_ftn1" name="_ftnref1"> <SPAN style="VERTICAL-ALIGN: super"> <SPAN style="mso-special-character: footnote" /> </SPAN> </A> <DIV style="mso-element: footnote-list"> <DIV id="ftn1" style="mso-element: footnote"> <DIV style="MARGIN: 0in"> <A title="" style="mso-footnote-id: ftn1" href="lbxfile:C:%5CProgram%20Files%5CLibronix%20DLS%5CCommon%5CLDLS%5CShells% 5CLDLS-en.lbxshl+AnnotationTemplate/Standard.html#_ftnref1" name="_ftn1"> <SPAN style="VERTICAL-ALIGN: super"> <SPAN style="mso-special-character: footnote" /> </SPAN> </A> <SPAN id="__spanCitationData">Bruce, A. B. (1995, c1877). <I>The training of the twelve or, Passages out of the Gospels, exhibiting the twelve disciples of Jesus under discipline for the apostleship</I> (0). Oak Harbor, WA: Logos Research Systems, Inc.</SPAN> </DIV> </DIV> </DIV> </html> </ap:NotesXhtmlData> </ap:NotesGroup> <ap:Offset CY="0." CX="-30" /> </ap:Topic> </ap:SubTopics> <ap:TopicViewGroup ViewIndex="0"> <ap:Collapsed Collapsed="true" /> <ap:DataContainerVisibility Collapsed="true" /> </ap:TopicViewGroup> <ap:Text TextAlignment="urn:mindjet:Left" PlainText="Sample Note 3b"> <ap:Font /> </ap:Text> <ap:NotesGroup> <ap:NotesXhtmlData PreviewPlainText="<P align=left></P>
<DIV style="MARGIN-TOP: 18pt; MARGIN-BOTTOM: 18pt; LINE- . . ."> <html xmlns="http://www.w3.org/1999/xhtml";> <P align="left" /> <DIV style="MARGIN-TOP: 18pt; MARGIN-BOTTOM: 18pt; LINE-HEIGHT: normal; TEXT-ALIGN: center"> <B> <SPAN lang="en-us"> <SPAN style="FONT-SIZE: 166%; FONT-FAMILY: Arial" /> </SPAN> </B> <B> <SPAN lang="en-us"> <SPAN style="FONT-SIZE: 166%; TEXT-TRANSFORM: capitalize; FONT-FAMILY: Arial"> <FONT size="6">FOREWORD BY OLAN HENDRIX</FONT> </SPAN> </SPAN> </B> </DIV> <DIV style="TEXT-INDENT: 18pt; LINE-HEIGHT: normal; TEXT-ALIGN: left"> <B> <SPAN lang="en-us"> <SPAN style="FONT-SIZE: 166%; FONT-FAMILY: Arial" /> </SPAN> </B> <SPAN lang="en-us">In more than twenty years in the ministry few books have influenced and helped me more than A. B. Bruces </SPAN> <I> <SPAN lang="en-us">The Training of the Twelve.</SPAN> </I> <SPAN lang="en-us"> I was delighted to discover that Kregel Publications was planning to reissue this very valuable book, and I thank God for their foresight in this undertaking. With confidence and enthusiasm I commend this volume to my fellow ministers throughout the English speaking world.</SPAN> </DIV> <A title="" style="mso-footnote-id: ftn1" href="lbxfile:C:%5CProgram%20Files%5CLibronix%20DLS%5CCommon%5CLDLS%5CShells% 5CLDLS-en.lbxshl+AnnotationTemplate/Standard.html#_ftn1" name="_ftnref1"> <SPAN style="VERTICAL-ALIGN: super"> <SPAN style="mso-special-character: footnote" /> </SPAN> </A> <DIV style="mso-element: footnote-list"> <DIV id="ftn1" style="mso-element: footnote"> <DIV style="MARGIN: 0in"> <A title="" style="mso-footnote-id: ftn1" href="lbxfile:C:%5CProgram%20Files%5CLibronix%20DLS%5CCommon%5CLDLS%5CShells% 5CLDLS-en.lbxshl+AnnotationTemplate/Standard.html#_ftnref1" name="_ftn1"> <SPAN style="VERTICAL-ALIGN: super"> <SPAN style="mso-special-character: footnote" /> </SPAN> </A> <SPAN id="__spanCitationData">Bruce, A. B. (1995, c1877). <I>The training of the twelve or, Passages out of the Gospels, exhibiting the twelve disciples of Jesus under discipline for the apostleship</I> (0). Oak Harbor, WA: Logos Research Systems, Inc.</SPAN> </DIV> </DIV> </DIV> </html> </ap:NotesXhtmlData> </ap:NotesGroup> <ap:Offset CY="0." CX="-30" /> </ap:Topic> </ap:SubTopics> <ap:TopicViewGroup ViewIndex="0"> <ap:Collapsed Collapsed="true" /> <ap:DataContainerVisibility Collapsed="true" /> </ap:TopicViewGroup> <ap:Text TextAlignment="urn:mindjet:Left" PlainText="Sample Note 3"> <ap:Font /> </ap:Text> <ap:NotesGroup> <ap:NotesXhtmlData PreviewPlainText=" . . ."> <html xmlns="http://www.w3.org/1999/xhtml"; /> </ap:NotesXhtmlData> </ap:NotesGroup> <ap:Offset CY="0." CX="-30" /> </ap:Topic> </ap:SubTopics> <ap:Text PlainText="Sample Note File"> <ap:Font /> </ap:Text> </ap:Topic> </ap:OneTopic> </ap:Map> _____________________________________________________________________________ _______ Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online. http://smallbusiness.yahoo.com/webhosting
|
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
|