c# - Read and selecting Css Style attribute values -


How can I read an element / tag below - using xsl + xpath, I have to format the XML output to read Trying to style alignment with style, but I can not understand it ... (Last Sahara C #)

Edit : To clarify my answer , I'm reading many html in documents, I'll have a list of the most acceptable tags that I need parsing Therefore, everything is not required for parsing, because I am using xslt, to transfer the document to XML in TM, I am keeping my solution in mind so far, though in view of XSL + xpath Keeping in mind if I want to use C # and Linux (to repeat on the document) - it's obvious that he will set up all the genres, With other additions.

  & lt; H1 style = "text-line: true;" & gt; Another chapter & lt; / H1>   

My XSL:

  & lt; Xsl: template match = "h1" & gt; & Lt; Fo: block color = "black" font-family = "ariel, verdana, non-serif" & gt; & Lt; Xsl: call-template name = "set-alignment" /> & Lt; For /: Block & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: Template name = "set-alignment" & gt; & Lt; XSL: Select & gt; & Lt; Xsl: when test = "@ align = 'left'" & gt; & Lt; Xsl: attribute name = "text-align" & gt; Start & lt; / Xsl: attribute & gt; & Lt; / XSL: When & gt; & Lt; Xsl: when test = "@ align = 'center'" & gt; & Lt; Xsl: attribute name = "text-align" & gt; Center & lt; / Xsl: attribute & gt; & Lt; / XSL: When & gt; & Lt; Xsl: when test = "@ align = 'right'" & gt; & Lt; Xsl: attribute name = "text-align" & gt; End & lt; / Xsl: attribute & gt; & Lt; / XSL: When & gt; & Lt; / XSL: Select & gt; & Lt; / XSL: Templates & gt;   

Note, there is only one style defined below, but can be very ... (underlined etc.)

desired output:

  and lt; H1 text-align = "start" text-decoration = "underline" & gt; Another chapter & lt; / H1>  

With the famous tokening pattern, this stylesheet:

 < Code> & lt; Xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/Transform" & gt; & Lt; Xsl: template match = "node () | @ *" & gt; & Lt; XSL: Copy & gt; & Lt; Xsl: apply-select template = "node () | @ *" /> & Lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "h1" & gt; & Lt; XSL: Copy & gt; & Lt; Xsl: Apply-Select Template = "@ * [Name (!! = 'style']" />   gt; & lt; / XSL: copy & gt; & lt; / XSL: template & gt; & lt; xsl: template name = "token-style" & gt; Lt; xsl: choose the ultimate name = "pString" = "string (style)" />>; XSL: select & gt; & lt; xsl: when test = "no ($ pString)" /> ; & Lt; xsl: When testing = "In ($ pString, ';')">  lt; xsl: with-param Select name = "pString" = "substring-before ($ pString, ';' ) "/> & Lt; / XSL: Call-templates & gt; & lt; xsl: call-template name =" tokenize-style "& gt; with xsl: param name =" pString " Select = "substring-after ($ pString, ';')" /> & lt; / XSL: call-template & gt; & lt; / XSL: when & gt; & lt; XSL: otherwise & Gt; & lt; xsl: attribute name = "{generalized-space (substrings-first ($ pString, ':'))} & gt; & lt; xsl: select value =" normal-location (after substring ($ PString, ':')) "/> & Lt; / XSL: Specialty & gt; & Lt; / XSL: otherwise & gt; & Lt; / XSL: Select & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;   

Output:

  & lt; H1 text-align = "right" & gt; Another chapter & lt; / H1>    

Comments