0

I am trying to write a two-way XHTML to FlowDocument (FD) XSLT transformation, and I'm running into a recurring issue - there are things you can do in HTML that don't make sense (at least in this early version) in a FD. For example, XHTML has the notion of an accesskey attribute, but there is no corresponding FD XAML element.

Even though the FD has no use for it, I need a way to store this information in the XAML of the FD so I can retrieve it later. Something along the lines of:

<xsl:template match=@accesskey>
    <InvisibleElement name="accesskey" value="." />
</xsl:template>

...but to my knowledge, there is no FD element that doesn't have a corresponding display. I suppose I could use an empty <Span /> or <Run />, but that could lead to issues if someone edits the document and inadvertently adds content where I don't expect it.

Another option might be:

<xsl:template match="@accesskey">
   <InlineUIContainer Tag="accesskey">
      <TextBlock Visibility="Collapsed" Tag="{.}" />
   </InlineUIContainer>
</xsl:template>

Since it wouldn't be visible, it'd be uneditable.

Suggestions?

Scott Baker
  • 10,013
  • 17
  • 56
  • 102
  • Tried ``? –  Sep 01 '15 at 17:13
  • @Will these elements/attributes will occur throughout the HTML document - if I *do* store them in a Resource, how will I know where to put them when I transform the FlowDocument back to HTML? – Scott Baker Sep 01 '15 at 19:19
  • Refer to other elements by their x:Names? Or create custom attributes using attached properties? –  Sep 01 '15 at 19:30
  • Since FlowDocuments are XAML, which is XML, I would assume you can simply store them in any element that is not in the FD or XAML namespace. Add an element in namespace `http://extra` (name doesn't matter, as long as MS doesn't know it), and you can roundtrip your transformation. – Abel Sep 02 '15 at 17:48

0 Answers0