XSLT Posts

|

Using XSLT to Break out a Nested Inline Element

Webucator uses an XHTML-based courseware system. At publishing time, we compile all the lessons, written in XHTML, into a single large XML file and then we use XSLT/XSL-FO to create a PDF.

We are now planning to submit several of our courses to the Microsoft Courseware Library. To do so, we need to get them into Microsoft Word. It would be a ton of work to convert them manually and then we would have to keep both version in sync.

So, I dove into WordProcessingML. I’ve looked at it several times before, but always walked away after an hour or two of frustration. This time, I pushed further as we now have a real incentive to get it working. It’s actually kind of cool. Maybe I’ll write a WordProcessingML course someday? Interested?

Anyway, right now I’m struggling with an XSLT problem that I hope someone might be able to help me with. Continue Reading »

|

Using XSLT to Break out a Nested Inline Element

Webucator uses an XHTML-based courseware system. At publishing time, we compile all the lessons, written in XHTML, into a single large XML file and then we use XSLT/XSL-FO to create a PDF.

We are now planning to submit several of our courses to the Microsoft Courseware Library. To do so, we need to get them into Microsoft Word. It would be a ton of work to convert them manually and then we would have to keep both version in sync.

So, I dove into WordProcessingML. I’ve looked at it several times before, but always walked away after an hour or two of frustration. This time, I pushed further as we now have a real incentive to get it working. It’s actually kind of cool. Maybe I’ll write a WordProcessingML course someday? Interested?

Anyway, right now I’m struggling with an XSLT problem that I hope someone might be able to help me with.

I’m starting with the following code from my source XML:

Some text and inline elements. Some more text and inline elements

And here’s my desired output:

	
		Some text and inline elements.

		...

 		Some more text and inline elements.

The issue is that the image needs to appear centered on a block by itself. I know there’s WordProcessingML markup for doing that within a paragraph, but I haven’t been able to get that to behave correctly even while working in Word 2010 directly.

In XSL-FO, this isn’t a problem, because you can simply nest one fo:block in another fo:block, but in WordProcessingML, that’s not allowed.

The above “Desired Output” markup works correctly in Word (meaning it displays like I want it to), but it’s an XSLT challenge.

Essentially, what I need is this:

	

			...

But, of course, that’s not well-formed XML, so it chokes.

Anybody know of a solution for this sort of problem?