0

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="http://www.netflix.com/ns/ttml/profile/nflx-tt" ttp:frameRate="24"
 ttp:frameRateMultiplier="1000 1001" ttp:dropMode="nonDrop" ttp:timeBase="smpte">
  <head>
    <styling>
      <style xml:id="style.default" tts:fontFamily="Arial" tts:fontSize="100%" tts:fontStyle="normal" tts:fontWeight="normal" tts:backgroundColor="transparent" tts:color="white" />
    </styling>
    <layout>
      <region xml:id="region.after.center" tts:displayAlign="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:23" region="region.after.center" style="style.default">And that was it.<br />That was his story, right?</p>
      <p begin="00:03:18:14" xml:id="p63" end="00:03:19:16" region="region.after.center" style="style.default">
        <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="http://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:00" region="region.after.center" style="style.default" 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">But 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

Note. I'm using C# and this happens when evaluating the xpath to extract matching content.

Mostafa
  • 33
  • 1
  • 8
  • There is nothing wrong with the XML, and no namespaces are getting added to your results. You're missing two concepts: (1) default namespace declarations apply to the element and all of its descendents, and (2) how to use XPath against namespaced XML (see duplicate link). Thanks. – kjhughes Nov 10 '17 at 18:53
  • This doesn't seem to explain why the namespace declaration `xmlns="http://www.w3.org/2000/xmlns"` appears in the result. This is a reserved namespace and should never be declared in lexical XML. – Michael Kay Nov 10 '17 at 18:55
  • Thank you Michael, I copied the wrong xmlns I'm getting in the result. I have modified the main question. So I'm not getting xmlns="http://www.w3.org/2000/xmlns"....so any ideas? – Mostafa Nov 10 '17 at 19:10
  • Also is it ok to use tts:fontStyle="italic" as an attribute withing pure html tag like . Because when I try to remove this attribute, I no longer get the extra xmlns in the tag. So is this correct? – Mostafa Nov 10 '17 at 19:19
  • Is it ok according to what basis? At the XML level, your document (including `tts:fontStyle="italic"`) is well-formed. Against the TTML1 XSDs, your document is valid. Against the TTML1 spec, such a span attribute is ok because `span` can take [*any attribute in TT Style namespace*](https://www.w3.org/TR/ttml1/#content-vocabulary-span). Hopefully this helps, but please note that your queries are drifting and should probably continue as a new, proper question, not as a discussion in comments. Thanks. – kjhughes Nov 11 '17 at 02:46

0 Answers0