Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Added support of optional "linkText" attribute for <xsd:xmlEntityRefe…
Browse files Browse the repository at this point in the history
…rence> elements

There was no way to change text of the link that will be generated for
<xmlEntityReference> element.  The link title is generated with static
function that cannot be overridden.  Instead of modifying link titles
within topics.index file, I added feature similar to
codeEntityReference: allow authors providing their own title for the
link.
  • Loading branch information
sergey-steinvil committed Jun 23, 2015
1 parent 3dddf35 commit 469ee06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 12 additions & 1 deletion etc/Schemas/XsdDocumentation.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,24 @@
</xs:annotation>
</xs:element>

<xs:element name="xmlEntityReference" type="xmlEntityUri">
<xs:element name="xmlEntityReference">
<xs:annotation>
<xs:documentation>
This element can be used to create links to XML entities, such as
elements, attributes, groups or types.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xmlEntityUri">
<xs:attribute name="linkText" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>The custom text of the link to use instead of topic's title.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

<xs:element name="examples" type="ddue:namedSectionType">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public override void Apply(XmlDocument document, string key)
if (nodes == null)
return;

foreach (XmlNode node in nodes)
foreach (XmlElement node in nodes)
{
var parentNode = node.ParentNode;
var uri = node.InnerText;
Expand All @@ -82,8 +82,11 @@ public override void Apply(XmlDocument document, string key)
var linkElement = document.CreateElement("ddue", "link", Namespaces.Maml);
linkElement.SetAttribute("href", Namespaces.XLink, entry.TopicId);
linkElement.SetAttribute("topicType_id", "3272D745-2FFC-48C4-9E9D-CF2B2B784D5F");
linkElement.InnerText = entry.LinkTitle;
parentNode.ReplaceChild(linkElement, node);
if (node.HasAttribute("linkText"))
linkElement.InnerText = node.GetAttribute("linkText");
else
linkElement.InnerText = entry.LinkTitle;
parentNode.ReplaceChild(linkElement, node);
}
}
}
Expand Down

0 comments on commit 469ee06

Please sign in to comment.