[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl-list Digest 17 Jan 2007 06:10:01 -0000 Issue 1
It's working now! Thank you so much for your help! Since I am new to
XSLT I was really stuck on this for some time. Your advice to use the
<debug> instruction was really helpful to me.
The solution looks like this: ---------------------------- WORD2007SAMPLE_DOCUMENT.XML ---------------------------- <?xml version="1.0"?> <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> <w:body> <w:p> <w:customXml w:element="pageTitle"> <w:r> <w:t>1. Web Page Title</w:t> </w:r> </w:customXml> </w:p> <w:p> <w:r> <w:t>Content A</w:t> </w:r> </w:p> <w:p> <w:r> <w:t>Content B</w:t> </w:r> </w:p> <w:p> <w:customXml w:element="pageTitle"> <w:r> <w:t>2. Web Page Title</w:t> </w:r> </w:customXml> </w:p> <w:p> <w:r> <w:t>Content C</w:t> </w:r> </w:p> <w:p> <w:r> <w:t>Content D</w:t> </w:r> </w:p> </w:body> </w:document> ---------------------------- OUTPUT.XML ---------------------------- <?xml version="1.0" encoding="utf-8"?> <root xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> <pageData> <pageTitle>1. Web Page Title</pageTitle> <pageContent> Content A and Content B </pageContent> </pageData> <pageData> <pageTitle>2. Web Page Title</pageTitle> <pageContent> Content C and Content D </pageContent> </pageData> </root> ---------------------------- TRANSFORM.XSL ---------------------------- <xsl:stylesheet version="2.0" xmlns:xsl=http://www.w3.org/1999/XSL/Transform xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> <xsl:output method="xml" indent="yes" encoding="utf-8" /> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:apply-templates select="//w:body"/> </xsl:template> <xsl:template match="w:body"> <root> <xsl:for-each-group select="*" group-starting-with="w:p[w:customXml/@w:element = 'pageTitle']"> <pageData> <pageTitle> <xsl:value-of select="."/> </pageTitle> <pageContent> <xsl:value-of select="current-group()/w:r/w:t"/> </pageContent> </pageData> </xsl:for-each-group> </root> </xsl:template> </xsl:stylesheet> Thanks again, Frank ------------------------------
|
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
|