xmlns attributes are added automatically to nodes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mostafa186
    New Member
    • Nov 2017
    • 1

    xmlns attributes are added automatically to nodes

    I'm new to xml and having an issue listed below:

    I have a sample xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http ://www.w3.org/ns/ttml#styling"
    xmlns:ttp="http ://www.w3.org/ns/ttml#parameter" xmlns:ttm="http ://www.w3.org/ns/ttml#metadata"
    ttp:profile="ht tp://www.netflix.com/ns/ttml/profile/nflx-tt" ttp:frameRate=" 24"
    ttp:frameRateMu ltiplier="1000 1001" ttp:dropMode="n onDrop" ttp:timeBase="s mpte">
    <head>
    <styling>
    <style xml:id="style.d efault" tts:fontFamily= "Arial" tts:fontSize="1 00%" tts:fontStyle=" normal" tts:fontWeight= "normal" tts:backgroundC olor="transpare nt" tts:color="whit e" />
    </styling>
    <layout>
    <region xml:id="region. after.center" tts:displayAlig n="after" tts:textAlign=" center" tts:origin="10% 10%" tts:extent="80% 80%" />
    </layout>
    </head>
    <body>
    <div xml:lang="en">
    <p begin="00:03:14 :09" xml:id="p62" end="00:03:16:2 3" region="region. after.center" style="style.de fault">And that was it.<br />That was his story, right?</p>
    <p begin="00:03:18 :14" xml:id="p63" end="00:03:19:1 6" region="region. after.center" style="style.de fault">
    <span tts:fontStyle=" italic">So now...</span>
    </p>
    </div>
    </body>
    </tt>

    Now I have a simple xpath : `//*[starts-with(name(),'d' )]` so it selects all elements under the div tag.

    The problem is when evaluating the expression against the xml, I get
    `xmlns="http://www.w3.org/ns/ttml"` in all `<p></p>` tags and also I get `xmlns:tts="htt p://www.w3.org/ns/ttml#styling"` in all `<span></span>` tags. Bewlo is a sample result of what is returned:

    <p begin="00:00:34 :23" xml:id="p2" end="00:00:36:0 0" region="region. after.center" style="style.de fault" xmlns="http://www.w3.org/ns/ttml">That was his story, right?</p>
    <span tts:fontStyle=" italic" xmlns:tts="http ://www.w3.org/ns/ttml#styling">B ut there’s a woman there<br /> So now...</span>

    so, is there is something wrong in the xml structure itself?

    when adding prefix to `xmlns="http://www.w3.org/ns/ttml"` I do not get it in `<p></p>` tags but still getting xmlns in the `<span></span>` tags.



    I appreciate if someone can help me out with this. Thanks in advance
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Which tools are you using to do this?
    When viewing your XML with Notepad++, and using the XML-plugin, the Xpath seems to result in what you expect
    Attached Files

    Comment

    Working...