Transform Server

<?xml version="1.0" encoding="utf-8"?>
<Document xmlns="urn:WebWorks-Document-Schema">
  <Styles>
    <ParagraphStyles>
      <ParagraphStyle name="Heading1">
        <Style>
          <Attribute name="font-size" value="large" />
          <Attribute name="font-weight" value="bold" />
          <Attribute name="margin-bottom" value="10pt" />
        </Style>
      </ParagraphStyle>
      <ParagraphStyle name="Body">
        <Style>
          <Attribute name="margin-bottom" value="6pt" />
        </Style>
      </ParagraphStyle>
      <ParagraphStyle name="Bulleted">
        <Style>
          <Attribute name="text-indent" value="-0.25in" />
          <Attribute name="margin-left" value="0.25in" />
          <Attribute name="color" value="blue" />
        </Style>
      </ParagraphStyle>
    </ParagraphStyles>
    <CharacterStyles>
      <CharacterStyle name="Default" />
    </CharacterStyles>
    <TableStyles>
      <TableStyle name="Default" />
    </TableStyles>
    <PageStyles>
      <PageStyle name="Default" />
    </PageStyles>
    <MarkerStyles>
      <MarkerStyle name="Default" />
    </MarkerStyles>
  </Styles>
  <Content>
    <Paragraph id="5000001" stylename="Heading1">
      <TextRun id="5000001-1">
        <Text value="Example WIF Document" />
      </TextRun>
    </Paragraph>
    <Paragraph id="5000002" stylename="Body">
      <TextRun id="5000002-1">
        <Text value="This is a document, the purpose of which, is to " />
        <Text value="demonstrate the WebWorks Intermeditate Format. " />
        <Text value=" This is, in fact, what WIF stands for." />
      </TextRun>
    </Paragraph>
    <Paragraph id="5000003" stylename="Bulleted">
      <TextRun id="5000003-1">
        <Text value="This is a bulleted paragraph.  I hope you like it." />
      </TextRun>
    </Paragraph>
  </Content>
</Document>

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  version="1.0"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:wwdoc="urn:WebWorks-Document-Schema"
  xmlns:wwmode="urn:WebWorks-Engine-Mode-Schema"
  exclude-result-prefixes="html xsl wwdoc wwmode"
>
  <xsl:output 
    method="xml" 
    version="1.0" 
    encoding="utf-8" 
    indent="yes" 
  />

  <xsl:namespace-alias 
    stylesheet-prefix="html" 
    result-prefix="#default" 
  />
  <xsl:strip-space elements="*" />

  <xsl:template match="/">
    <html:html>
      <html:head>
        <html:title>
          <xsl:apply-templates
            select="/wwdoc:Document/wwdoc:Content/wwdoc:Paragraph[1]"
            mode="wwmode:title"
          />
        </html:title>

        <html:style type="text/css" xml:space="preserve">
          <xsl:apply-templates
            select="/wwdoc:Document/wwdoc:Styles/wwdoc:ParagraphStyles"
            mode="wwmode:style"
          />
        </html:style>
      </html:head>
      <html:body>
        <xsl:apply-templates
          select="/wwdoc:Document/wwdoc:Content/*" 
          mode="wwmode:content" 
        />
      </html:body>
    </html:html>
  </xsl:template>

  <!-- wwmode:title -->
  <!--              -->
  <xsl:template match="wwdoc:Paragraph" mode="wwmode:title">
    <xsl:for-each select="./wwdoc:TextRun">
      <xsl:for-each select="wwdoc:Text">
        <xsl:value-of select="@value" />
      </xsl:for-each>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="comment() | processing-instruction() | text() | node()" mode="wwmode:title">
    <!-- pass -->
    <!--      -->
  </xsl:template>

  <!-- wwmode:style -->
  <!--              -->
  <xsl:template match="wwdoc:ParagraphStyles" mode="wwmode:style">
    <xsl:apply-templates
      select="wwdoc:ParagraphStyle"
      mode="wwmode:style"
    />
  </xsl:template>

  <xsl:template match="wwdoc:ParagraphStyle" mode="wwmode:style">
     <xsl:text>div.</xsl:text>
    <xsl:value-of select="@name" />
    <xsl:text xml:space="preserve"> {
</xsl:text>

   <xsl:apply-templates
      select="wwdoc:Style[1]/wwdoc:Attribute"
      mode="wwmode:style"
    />

     <xsl:text xml:space="preserve">
}
</xsl:text>
  </xsl:template>

  <xsl:template match="wwdoc:Attribute" mode="wwmode:style">
    <xsl:text xml:space="preserve">  </xsl:text>
    <xsl:value-of select="@name" />
    <xsl:text xml:space="preserve">: </xsl:text>
    <xsl:value-of select="@value" />
    <xsl:text xml:space="preserve">;
</xsl:text>
  </xsl:template>

  <xsl:template match="comment() | processing-instruction() | text() | node()" mode="wwmode:style">
    <!-- pass -->
    <!--      -->
  </xsl:template>

  <!-- wwmode:content -->
  <!--                -->
  <xsl:template match="wwdoc:Paragraph" mode="wwmode:content">
    <html:div id="{@id}" class="{@stylename}">
      <xsl:apply-templates
        select="wwdoc:TextRun"
        mode="wwmode:content"
      />
    </html:div>
  </xsl:template>

  <xsl:template match="wwdoc:TextRun" mode="wwmode:content">
    <xsl:apply-templates
      select="wwdoc:Text"
      mode="wwmode:content"
    />
  </xsl:template>

  <xsl:template match="wwdoc:Text" mode="wwmode:content">
    <xsl:value-of select="@value" />
  </xsl:template>

  <xsl:template match="comment() | processing-instruction() | text() | node()" mode="wwmode:content">
    <!-- pass -->
    <!--      -->
  </xsl:template>

</xsl:stylesheet>

JesseWiles/TransformServer (last edited 2009-10-19 16:48:44 by JesseWiles)