Author: alessio.soldano(a)jboss.com
Date: 2010-10-26 13:50:18 -0400 (Tue, 26 Oct 2010)
New Revision: 13192
Modified:
projects/magnolia2docbook/src/org/jboss/util/magnolia2docbook/XHTMLPage.java
projects/magnolia2docbook/src/org/jboss/util/magnolia2docbook/xhtml2docbook.xsl
Log:
Generate unique ids over different pages and avoid empty ids (they hurt the xsl fo to
generate pdf)
Modified: projects/magnolia2docbook/src/org/jboss/util/magnolia2docbook/XHTMLPage.java
===================================================================
---
projects/magnolia2docbook/src/org/jboss/util/magnolia2docbook/XHTMLPage.java 2010-10-26
14:58:08 UTC (rev 13191)
+++
projects/magnolia2docbook/src/org/jboss/util/magnolia2docbook/XHTMLPage.java 2010-10-26
17:50:18 UTC (rev 13192)
@@ -304,14 +304,14 @@
if (hLevel == nestedSectionLevel + 1)
{
nestedSectionLevel++;
- startSection(xmlr, xtw);
+ startSection(xmlr, xtw, name);
break;
}
else if (hLevel == nestedSectionLevel)
{
xtw.writeEndElement();
xtw.writeCharacters("\n");
- startSection(xmlr, xtw);
+ startSection(xmlr, xtw, name);
break;
}
else if (hLevel < nestedSectionLevel)
@@ -323,7 +323,7 @@
xtw.writeCharacters("\n");
}
nestedSectionLevel = hLevel;
- startSection(xmlr, xtw);
+ startSection(xmlr, xtw, name);
break;
}
else if (hLevel > nestedSectionLevel &&
nestedSectionLevel == lowerNestedSectionLevel && lowerNestedSectionLevel ==
BASE_H_LEVEL)
@@ -331,7 +331,7 @@
//when -for instance- the page does not use anything below h4
nestedSectionLevel = hLevel;
lowerNestedSectionLevel = hLevel - 1;
- startSection(xmlr, xtw);
+ startSection(xmlr, xtw, name);
break;
}
else
@@ -439,14 +439,15 @@
}
}
- private static void startSection(XMLStreamReader xmlr, XMLStreamWriter xtw) throws
XMLStreamException
+ private static void startSection(XMLStreamReader xmlr, XMLStreamWriter xtw, String
idPrefix) throws XMLStreamException
{
xtw.writeStartElement("", DIV.getLocalPart(), DIV.getNamespaceURI());
xtw.writeAttribute(CLASS, SECTION);
String id = xmlr.getAttributeValue(null, ID);
if (id != null)
{
- xtw.writeAttribute(ID, id);
+
+ xtw.writeAttribute(ID, idPrefix != null ? idPrefix + "_" + id : id);
}
xtw.writeStartElement(xmlr.getPrefix(), xmlr.getLocalName(),
xmlr.getNamespaceURI());
copyElementAttributes(xmlr, xtw, ID);
Modified: projects/magnolia2docbook/src/org/jboss/util/magnolia2docbook/xhtml2docbook.xsl
===================================================================
---
projects/magnolia2docbook/src/org/jboss/util/magnolia2docbook/xhtml2docbook.xsl 2010-10-26
14:58:08 UTC (rev 13191)
+++
projects/magnolia2docbook/src/org/jboss/util/magnolia2docbook/xhtml2docbook.xsl 2010-10-26
17:50:18 UTC (rev 13192)
@@ -14,7 +14,7 @@
<xsl:output method="xml" indent="no"/>
<xsl:param name="filename"></xsl:param>
-<xsl:param name="prefix">wb</xsl:param>
+<xsl:param name="prefix">chap</xsl:param>
<xsl:param name="graphics_location">images/</xsl:param>
<!-- Main block-level conversions -->
@@ -23,7 +23,7 @@
</xsl:template>
<!-- This template converts each HTML file encountered into a DocBook
- section. For a title, it selects the first h1 element -->
+ chapter. For a title, it selects the head/title element -->
<xsl:template match="html:body">
<chapter>
<xsl:if test="$filename != ''">
@@ -34,9 +34,6 @@
</xsl:attribute>
</xsl:if>
<title>
- <!-- <xsl:value-of select=".//html:h1[1]
- |.//html:h2[1]
- |.//html:h3[1]"/> -->
<xsl:value-of select="parent::node()/html:head/html:title"/>
</title>
<xsl:apply-templates select="*"/>
@@ -391,9 +388,13 @@
<!-- JBossWS customizations -->
<xsl:template match="html:div[@class = 'section']">
<section>
- <xsl:attribute name="id">
- <xsl:value-of select="@id"/>
- </xsl:attribute>
+ <xsl:choose>
+ <xsl:when test="@id">
+ <xsl:attribute name="id">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
<title><xsl:value-of select="child::node()[1]"/></title>
<xsl:apply-templates select="child::node()[position() != 1]"/>
</section>
Show replies by date