I try to remove the tag title using XSLT. But it`s not removing. Can one can recommdate solution for remove anchor title.
XML File
<?xml version="1.0" encoding="utf-8"?>
<RichText xmlns="uuid:e25b1476-ce87-4a67-a22b-b82a752810e0">
<Content>
<a xmlns="http://www.w3.org/1999/xhtml" href="http://www.google.com" title="Google Title">
Hyperlink
</a>
</Content>
</RichText>
XSLT File:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></xsl:output>
<xsl:template match="/ | node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*">
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="*[ (self::br or self::p or self::div) and normalize-space(translate(., ' ', '')) = '' and not(@*) and not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) and not(following::node()[not( (self::text() or self::br or self::p or self::div) and normalize-space(translate(., ' ', '')) = '' and not(@*) and not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) )]) ]">
<!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks -->
</xsl:template>
<xsl:template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]">
<!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space -->
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="utf-8"?>
<RichText xmlns="uuid:e25b1476-ce87-4a67-a22b-b82a752810e0">
<Content>
<a xmlns="http://www.w3.org/1999/xhtml" href="http://www.google.com">
Hyperlink
</a>
</Content>
</RichText>
答案 0 :(得分:3)
如果您使用的是identity transformation,则需要使用空模板的该属性的规则。
此输入
<RichText xmlns="uuid:e25b1476-ce87-4a67-a22b-b82a752810e0">
<Content>
<a xmlns="http://www.w3.org/1999/xhtml" href="http://www.google.com" title="Google Title">
Hyperlink
</a>
</Content>
</RichText>
使用此样式表
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml" >
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xhtml:a/@title"/>
</xsl:stylesheet>
输出
<RichText xmlns="uuid:e25b1476-ce87-4a67-a22b-b82a752810e0">
<Content>
<a xmlns="http://www.w3.org/1999/xhtml" href="http://www.google.com">
Hyperlink
</a>
</Content>
</RichText>
注意:研究名称空间的使用。
答案 1 :(得分:0)
describe('Navigate to test website and check the Home button', function(){
before('Clear the cookies and run the test', ()=>{
cy.clearCookies();
})
it('Verify whether the Home button is displaying in the test portal', function(){
const newToken = cy.getLoginToken();
cy.log(newToken);
cy.visit(newToken);
})
})